Akashik Protocol
Reference

createField

Create a new Field — the shared memory surface agents read from and write to.

Signature

import { createField } from '@akashikprotocol/core'

function createField(options?: FieldOptions): Field

type FieldOptions = {
  minIntentLength?: number  // default: 10
  adapter?: StorageAdapter  // default: an in-memory adapter
}

Options

OptionTypeDefaultDescription
minIntentLengthnumber10Minimum character count for any intent string, after trimming. Setting to 0 is legal but logs a warning on first write.
adapterStorageAdapterin-memoryStorage backend. Defaults to a non-durable in-memory adapter. Pass a FileAdapter or PostgresAdapter (v0.3+) for persistence. See Storage Adapters.

Returns

A Field instance. All methods on the instance return Promises — the async signature is identical whether the underlying adapter is in-memory or durable.

Persistence is opt-in

By default, createField() uses an in-memory store — all state is lost when the process exits. As of v0.3, pass a durable adapter (file-based or Postgres) to survive restarts and share a Field across processes:

import { createField } from '@akashikprotocol/core'
import { createFileAdapter } from '@akashikprotocol/core/file'

const adapter = createFileAdapter({ path: './field.jsonl' })
await adapter.init()

const field = createField({ adapter })

Examples

// Default — in-memory, 10-character minimum intent
const field = createField()

// Custom intent floor
const field = createField({ minIntentLength: 20 })

// No minimum (not recommended — intent quality matters for relevance scoring)
const field = createField({ minIntentLength: 0 })

// Durable field backed by a file adapter
const adapter = createFileAdapter({ path: './field.jsonl' })
await adapter.init()
const durableField = createField({ adapter })

Notes

  • A single Field can serve an entire application. Use multiple Fields only if you need hard isolation between distinct agent populations.
  • All methods on the returned Field are async regardless of adapter — the promise resolves once the operation is durable (or applied in-memory).