@fabric-harness/sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +73 -0
  3. package/dist/agent-definition.d.ts +61 -0
  4. package/dist/agent-definition.d.ts.map +1 -0
  5. package/dist/agent-definition.js +52 -0
  6. package/dist/agent-definition.js.map +1 -0
  7. package/dist/agent.d.ts +13 -0
  8. package/dist/agent.d.ts.map +1 -0
  9. package/dist/agent.js +99 -0
  10. package/dist/agent.js.map +1 -0
  11. package/dist/context-budget.d.ts +20 -0
  12. package/dist/context-budget.d.ts.map +1 -0
  13. package/dist/context-budget.js +27 -0
  14. package/dist/context-budget.js.map +1 -0
  15. package/dist/context.d.ts +3 -0
  16. package/dist/context.d.ts.map +1 -0
  17. package/dist/context.js +8 -0
  18. package/dist/context.js.map +1 -0
  19. package/dist/error.d.ts +25 -0
  20. package/dist/error.d.ts.map +1 -0
  21. package/dist/error.js +48 -0
  22. package/dist/error.js.map +1 -0
  23. package/dist/filesystem-source.d.ts +69 -0
  24. package/dist/filesystem-source.d.ts.map +1 -0
  25. package/dist/filesystem-source.js +109 -0
  26. package/dist/filesystem-source.js.map +1 -0
  27. package/dist/history.d.ts +16 -0
  28. package/dist/history.d.ts.map +1 -0
  29. package/dist/history.js +118 -0
  30. package/dist/history.js.map +1 -0
  31. package/dist/index.d.ts +44 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +25 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/lite.d.ts +46 -0
  36. package/dist/lite.d.ts.map +1 -0
  37. package/dist/lite.js +38 -0
  38. package/dist/lite.js.map +1 -0
  39. package/dist/loop.d.ts +41 -0
  40. package/dist/loop.d.ts.map +1 -0
  41. package/dist/loop.js +94 -0
  42. package/dist/loop.js.map +1 -0
  43. package/dist/mcp-stdio.d.ts +28 -0
  44. package/dist/mcp-stdio.d.ts.map +1 -0
  45. package/dist/mcp-stdio.js +102 -0
  46. package/dist/mcp-stdio.js.map +1 -0
  47. package/dist/mcp.d.ts +40 -0
  48. package/dist/mcp.d.ts.map +1 -0
  49. package/dist/mcp.js +153 -0
  50. package/dist/mcp.js.map +1 -0
  51. package/dist/model.d.ts +204 -0
  52. package/dist/model.d.ts.map +1 -0
  53. package/dist/model.js +661 -0
  54. package/dist/model.js.map +1 -0
  55. package/dist/otel.d.ts +17 -0
  56. package/dist/otel.d.ts.map +1 -0
  57. package/dist/otel.js +25 -0
  58. package/dist/otel.js.map +1 -0
  59. package/dist/policy.d.ts +54 -0
  60. package/dist/policy.d.ts.map +1 -0
  61. package/dist/policy.js +148 -0
  62. package/dist/policy.js.map +1 -0
  63. package/dist/providers.d.ts +37 -0
  64. package/dist/providers.d.ts.map +1 -0
  65. package/dist/providers.js +265 -0
  66. package/dist/providers.js.map +1 -0
  67. package/dist/redaction.d.ts +11 -0
  68. package/dist/redaction.d.ts.map +1 -0
  69. package/dist/redaction.js +41 -0
  70. package/dist/redaction.js.map +1 -0
  71. package/dist/result.d.ts +7 -0
  72. package/dist/result.d.ts.map +1 -0
  73. package/dist/result.js +105 -0
  74. package/dist/result.js.map +1 -0
  75. package/dist/runtime-mode.d.ts +30 -0
  76. package/dist/runtime-mode.d.ts.map +1 -0
  77. package/dist/runtime-mode.js +42 -0
  78. package/dist/runtime-mode.js.map +1 -0
  79. package/dist/sandbox.d.ts +247 -0
  80. package/dist/sandbox.d.ts.map +1 -0
  81. package/dist/sandbox.js +922 -0
  82. package/dist/sandbox.js.map +1 -0
  83. package/dist/schema.d.ts +37 -0
  84. package/dist/schema.d.ts.map +1 -0
  85. package/dist/schema.js +121 -0
  86. package/dist/schema.js.map +1 -0
  87. package/dist/session.d.ts +60 -0
  88. package/dist/session.d.ts.map +1 -0
  89. package/dist/session.js +762 -0
  90. package/dist/session.js.map +1 -0
  91. package/dist/store.d.ts +48 -0
  92. package/dist/store.d.ts.map +1 -0
  93. package/dist/store.js +348 -0
  94. package/dist/store.js.map +1 -0
  95. package/dist/telemetry.d.ts +15 -0
  96. package/dist/telemetry.d.ts.map +1 -0
  97. package/dist/telemetry.js +51 -0
  98. package/dist/telemetry.js.map +1 -0
  99. package/dist/tools.d.ts +131 -0
  100. package/dist/tools.d.ts.map +1 -0
  101. package/dist/tools.js +235 -0
  102. package/dist/tools.js.map +1 -0
  103. package/dist/types.d.ts +343 -0
  104. package/dist/types.d.ts.map +1 -0
  105. package/dist/types.js +2 -0
  106. package/dist/types.js.map +1 -0
  107. package/package.json +71 -0
package/dist/error.js ADDED
@@ -0,0 +1,48 @@
1
+ import { redactJson } from './redaction.js';
2
+ export class FabricError extends Error {
3
+ code;
4
+ details;
5
+ publicMessage;
6
+ publicDetails;
7
+ retryable;
8
+ constructor(options) {
9
+ super(options.message, options.cause !== undefined ? { cause: options.cause } : undefined);
10
+ this.name = 'FabricError';
11
+ this.code = options.code;
12
+ if (options.details !== undefined)
13
+ this.details = redactJson(options.details);
14
+ this.publicMessage = options.publicMessage ?? safePublicMessage(options.code, options.message);
15
+ if (options.publicDetails !== undefined)
16
+ this.publicDetails = redactJson(options.publicDetails);
17
+ this.retryable = options.retryable ?? false;
18
+ }
19
+ toJSON(audience = process.env.FABRIC_MODE === 'production' ? 'public' : 'developer') {
20
+ const json = { name: this.name, code: this.code, message: audience === 'public' ? this.publicMessage : redactJson(this.message), retryable: this.retryable };
21
+ const details = audience === 'public' ? this.publicDetails : this.details;
22
+ if (details !== undefined)
23
+ json.details = redactJson(details);
24
+ return json;
25
+ }
26
+ toPublicJSON() {
27
+ return this.toJSON('public');
28
+ }
29
+ toDeveloperJSON() {
30
+ return this.toJSON('developer');
31
+ }
32
+ }
33
+ function safePublicMessage(code, message) {
34
+ if (process.env.FABRIC_MODE !== 'production')
35
+ return redactJson(message);
36
+ if (code === 'UNKNOWN')
37
+ return 'An unexpected Fabric Harness error occurred.';
38
+ return redactJson(message);
39
+ }
40
+ export function isFabricError(error) {
41
+ return error instanceof FabricError;
42
+ }
43
+ export function toFabricError(error, fallback) {
44
+ if (isFabricError(error))
45
+ return error;
46
+ return new FabricError({ ...fallback, cause: error });
47
+ }
48
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAsC5C,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,IAAI,CAAkB;IACtB,OAAO,CAAc;IACrB,aAAa,CAAS;IACtB,aAAa,CAAc;IAC3B,SAAS,CAAU;IAE5B,YAAY,OAA2B;QACrC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAC3F,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS;YAAE,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC9E,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAC/F,IAAI,OAAO,CAAC,aAAa,KAAK,SAAS;YAAE,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAChG,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;IAC9C,CAAC;IAED,MAAM,CAAC,WAAmC,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW;QACzG,MA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,0 +1,69 @@
1
+ import type { SandboxEnv, SandboxFactory } from './sandbox.js';
2
+ import type { SandboxBackend } from './types.js';
3
+ /**
4
+ * A read-only content source that can be mounted into a sandbox at
5
+ * sandbox-creation time. The agent then has built-in `read`, `glob`,
6
+ * and `grep` tools available over the mounted content — no retrieval
7
+ * pipeline, no embeddings, no vector store required.
8
+ *
9
+ * Sources are intentionally minimal: they yield (path, content) pairs.
10
+ * Implementations decide how to enumerate (eager vs lazy is up to the
11
+ * source author) — the mount step pulls the full set into the sandbox.
12
+ */
13
+ export interface FilesystemSource {
14
+ /** Stable name for telemetry / logs. */
15
+ readonly name?: string;
16
+ /** Yield path/content pairs. Paths are relative to the mount root. */
17
+ entries(): AsyncIterable<FilesystemEntry>;
18
+ }
19
+ export interface FilesystemEntry {
20
+ /** Path relative to the mount point (no leading slash). */
21
+ path: string;
22
+ content: string | Uint8Array;
23
+ /** Optional metadata; reserved for future use (mtime, content-type). */
24
+ metadata?: Record<string, unknown>;
25
+ }
26
+ export interface MountedSource {
27
+ source: FilesystemSource;
28
+ /** Absolute path inside the sandbox where this source is mounted. */
29
+ mountAt?: string;
30
+ }
31
+ /**
32
+ * Read a host directory recursively as a read-only source.
33
+ *
34
+ * `include` is called for each candidate file path (relative to
35
+ * `hostPath`). Return `false` to skip. Defaults to including everything.
36
+ */
37
+ export declare function localDirectorySource(hostPath: string, options?: {
38
+ name?: string;
39
+ include?: (relativePath: string) => boolean;
40
+ }): FilesystemSource;
41
+ /**
42
+ * Build a source from an in-memory map of `path -> content`. Useful for
43
+ * tests, fixtures, and small static knowledge bases bundled into the
44
+ * agent module itself.
45
+ */
46
+ export declare function inMemorySource(files: Record<string, string | Uint8Array>, options?: {
47
+ name?: string;
48
+ }): FilesystemSource;
49
+ /**
50
+ * Wrap a sandbox backend or factory so each new sandbox is pre-populated
51
+ * with the contents of one or more `FilesystemSource`s. The result is a
52
+ * `SandboxFactory` that can be passed directly to `init({ sandbox })`.
53
+ *
54
+ * ```ts
55
+ * const sandbox = withFilesystemSources('empty', [{
56
+ * mountAt: '/workspace/kb',
57
+ * source: localDirectorySource('./knowledge-base'),
58
+ * }]);
59
+ *
60
+ * const agent = await init({ sandbox, model: 'anthropic/claude-sonnet-4-6' });
61
+ * ```
62
+ *
63
+ * The agent's built-in `grep`, `glob`, and `read` tools then operate on
64
+ * the mounted content directly. Writes to mounted paths are not blocked
65
+ * by the SDK — sources are conventionally read-only; treat the agent's
66
+ * role/skill prompts as the place to enforce that.
67
+ */
68
+ export declare function withFilesystemSources(base: SandboxBackend | SandboxFactory | SandboxEnv, sources: MountedSource[]): SandboxFactory;
69
+ //# sourceMappingURL=filesystem-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem-source.d.ts","sourceRoot":"","sources":["../src/filesystem-source.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAyB,MAAM,cAAc,CAAC;AACtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wCAAwC;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,sEAAsE;IACtE,OAAO,IAAI,aAAa,CAAC,eAAe,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,gBAAgB,CAAC;IACzB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAA;CAAO,GAAG,gBAAgB,CASrJ;AAwBD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,EAAE,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,gBAAgB,CAU5H;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,cAAc,GAAG,cAAc,GAAG,UAAU,EAClD,OAAO,EAAE,aAAa,EAAE,GACvB,cAAc,CAehB"}
@@ -0,0 +1,109 @@
1
+ import { promises as fs } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { createSandboxEnv } from './sandbox.js';
4
+ /**
5
+ * Read a host directory recursively as a read-only source.
6
+ *
7
+ * `include` is called for each candidate file path (relative to
8
+ * `hostPath`). Return `false` to skip. Defaults to including everything.
9
+ */
10
+ export function localDirectorySource(hostPath, options = {}) {
11
+ const include = options.include ?? (() => true);
12
+ const name = options.name ?? `local:${hostPath}`;
13
+ return {
14
+ name,
15
+ async *entries() {
16
+ yield* walkDirectory(hostPath, '', include);
17
+ },
18
+ };
19
+ }
20
+ async function* walkDirectory(root, prefix, include) {
21
+ const dirHandle = path.join(root, prefix);
22
+ let entries;
23
+ try {
24
+ entries = await fs.readdir(dirHandle, { withFileTypes: true });
25
+ }
26
+ catch {
27
+ return;
28
+ }
29
+ for (const entry of entries) {
30
+ const relative = prefix ? path.posix.join(prefix, entry.name) : entry.name;
31
+ if (entry.isDirectory()) {
32
+ yield* walkDirectory(root, relative, include);
33
+ continue;
34
+ }
35
+ if (!entry.isFile())
36
+ continue;
37
+ if (!include(relative))
38
+ continue;
39
+ const absolute = path.join(root, relative);
40
+ const content = await fs.readFile(absolute);
41
+ yield { path: relative, content: new Uint8Array(content) };
42
+ }
43
+ }
44
+ /**
45
+ * Build a source from an in-memory map of `path -> content`. Useful for
46
+ * tests, fixtures, and small static knowledge bases bundled into the
47
+ * agent module itself.
48
+ */
49
+ export function inMemorySource(files, options = {}) {
50
+ const name = options.name ?? 'in-memory';
51
+ return {
52
+ name,
53
+ async *entries() {
54
+ for (const [filePath, content] of Object.entries(files)) {
55
+ yield { path: filePath.replace(/^\//, ''), content };
56
+ }
57
+ },
58
+ };
59
+ }
60
+ /**
61
+ * Wrap a sandbox backend or factory so each new sandbox is pre-populated
62
+ * with the contents of one or more `FilesystemSource`s. The result is a
63
+ * `SandboxFactory` that can be passed directly to `init({ sandbox })`.
64
+ *
65
+ * ```ts
66
+ * const sandbox = withFilesystemSources('empty', [{
67
+ * mountAt: '/workspace/kb',
68
+ * source: localDirectorySource('./knowledge-base'),
69
+ * }]);
70
+ *
71
+ * const agent = await init({ sandbox, model: 'anthropic/claude-sonnet-4-6' });
72
+ * ```
73
+ *
74
+ * The agent's built-in `grep`, `glob`, and `read` tools then operate on
75
+ * the mounted content directly. Writes to mounted paths are not blocked
76
+ * by the SDK — sources are conventionally read-only; treat the agent's
77
+ * role/skill prompts as the place to enforce that.
78
+ */
79
+ export function withFilesystemSources(base, sources) {
80
+ return async (options) => {
81
+ const sandbox = await resolveBaseSandbox(base, options);
82
+ for (const mounted of sources) {
83
+ const mountAt = mounted.mountAt ?? sandbox.cwd;
84
+ await ensureDirectory(sandbox, mountAt);
85
+ for await (const entry of mounted.source.entries()) {
86
+ const target = path.posix.join(mountAt, entry.path);
87
+ const parent = path.posix.dirname(target);
88
+ await ensureDirectory(sandbox, parent);
89
+ await sandbox.writeFile(target, entry.content);
90
+ }
91
+ }
92
+ return sandbox;
93
+ };
94
+ }
95
+ async function resolveBaseSandbox(base, options) {
96
+ if (typeof base === 'object' && base !== null && 'exec' in base)
97
+ return base;
98
+ if (typeof base === 'function')
99
+ return base(options);
100
+ return createSandboxEnv({ ...options, backend: base });
101
+ }
102
+ async function ensureDirectory(sandbox, dir) {
103
+ if (!dir || dir === '/' || dir === '.')
104
+ return;
105
+ if (await sandbox.exists(dir))
106
+ return;
107
+ await sandbox.mkdir(dir, { recursive: true });
108
+ }
109
+ //# sourceMappingURL=filesystem-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem-source.js","sourceRoot":"","sources":["../src/filesystem-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAmChD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB,EAAE,UAA0E,EAAE;IACjI,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,SAAS,QAAQ,EAAE,CAAC;IACjD,OAAO;QACL,IAAI;QACJ,KAAK,CAAC,CAAC,OAAO;YACZ,KAAK,CAAC,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC;KACF,CAAC;AACJ,CAAC;AAED,KAAK,SAAS,CAAC,CAAC,aAAa,CAAC,IAAY,EAAE,MAAc,EAAE,OAA0C;IACpG,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC1C,IAAI,OAAmC,CAAC;IACxC,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IACjE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;IACT,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,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AM,CAAC,GAAG,CAAC;QAAE,OAAO;IACtC,MAAM,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { ModelMessage } from './model.js';
2
+ import type { Role, SessionData, SessionEntry } from './types.js';
3
+ export declare const DEFAULT_HEADLESS_PREAMBLE = "You are running in headless autonomous mode (background-agent mode) with no human operator assumed. Work autonomously: Do not ask clarifying questions or wait for in-band user input. Make safe, reasonable assumptions when possible; if blocked by missing credentials, unavailable capabilities, denied policy, or required approvals, fail closed with a concise actionable explanation. Irreversible or high-risk actions must go through policy/approval gates, not natural-language confirmation. Summarize what you did and any remaining risks or follow-ups.";
4
+ export declare class SessionHistory {
5
+ private readonly entries;
6
+ private readonly byId;
7
+ private readonly leafId;
8
+ private constructor();
9
+ static fromData(data: SessionData | undefined): SessionHistory;
10
+ getActivePath(): SessionEntry[];
11
+ getLatestCompaction(): SessionEntry | undefined;
12
+ buildContextEntries(): SessionEntry[];
13
+ buildModelMessages(role?: Role): ModelMessage[];
14
+ }
15
+ export declare function buildModelMessagesFromHistory(data: SessionData | undefined, role?: Role): ModelMessage[];
16
+ //# sourceMappingURL=history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,YAAY,CAAC;AAC9D,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAElE,eAAO,MAAM,yBAAyB,4iBAA4iB,CAAC;AAEnlB,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA4B;IACjD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAE5C,OAAO;IAMP,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,cAAc;IAI9D,aAAa,IAAI,YAAY,EAAE;IAU/B,mBAAmB,IAAI,YAAY,GAAG,SAAS;IAS/C,mBAAmB,IAAI,YAAY,EAAE;IAgBrC,kBAAkB,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,YAAY,EAAE;CAiChD;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,YAAY,EAAE,CAExG"}
@@ -0,0 +1,118 @@
1
+ export const DEFAULT_HEADLESS_PREAMBLE = 'You are running in headless autonomous mode (background-agent mode) with no human operator assumed. Work autonomously: Do not ask clarifying questions or wait for in-band user input. Make safe, reasonable assumptions when possible; if blocked by missing credentials, unavailable capabilities, denied policy, or required approvals, fail closed with a concise actionable explanation. Irreversible or high-risk actions must go through policy/approval gates, not natural-language confirmation. Summarize what you did and any remaining risks or follow-ups.';
2
+ export class SessionHistory {
3
+ entries;
4
+ byId;
5
+ leafId;
6
+ constructor(entries, leafId) {
7
+ this.entries = [...entries];
8
+ this.leafId = leafId;
9
+ this.byId = new Map(entries.map((entry) => [entry.id, entry]));
10
+ }
11
+ static fromData(data) {
12
+ return new SessionHistory(data?.entries ?? [], data?.leafId);
13
+ }
14
+ getActivePath() {
15
+ const path = [];
16
+ let current = this.leafId ? this.byId.get(this.leafId) : this.entries.at(-1);
17
+ while (current) {
18
+ path.push(current);
19
+ current = current.parentId ? this.byId.get(current.parentId) : undefined;
20
+ }
21
+ return path.reverse();
22
+ }
23
+ getLatestCompaction() {
24
+ const path = this.getActivePath();
25
+ for (let index = path.length - 1; index >= 0; index -= 1) {
26
+ const entry = path[index];
27
+ if (entry?.type === 'compaction')
28
+ return entry;
29
+ }
30
+ return undefined;
31
+ }
32
+ buildContextEntries() {
33
+ const path = this.getActivePath();
34
+ const compaction = this.getLatestCompaction();
35
+ if (!compaction)
36
+ return path;
37
+ const firstKeptEntryId = typeof compaction.data?.firstKeptEntryId === 'string'
38
+ ? compaction.data.firstKeptEntryId
39
+ : undefined;
40
+ const firstKeptIndex = firstKeptEntryId
41
+ ? path.findIndex((entry) => entry.id === firstKeptEntryId)
42
+ : -1;
43
+ const compactionIndex = path.findIndex((entry) => entry.id === compaction.id);
44
+ const keptStart = firstKeptIndex >= 0 ? firstKeptIndex : compactionIndex + 1;
45
+ return [compaction, ...path.slice(keptStart).filter((entry) => entry.id !== compaction.id)];
46
+ }
47
+ buildModelMessages(role) {
48
+ const messages = [{ role: 'system', content: role ? `${DEFAULT_HEADLESS_PREAMBLE}\n\n${role.content}` : DEFAULT_HEADLESS_PREAMBLE }];
49
+ const entries = this.buildContextEntries();
50
+ let i = 0;
51
+ while (i < entries.length) {
52
+ const entry = entries[i];
53
+ if (!entry) {
54
+ i += 1;
55
+ continue;
56
+ }
57
+ // Group consecutive tool_call entries into a single assistant message with toolCalls
58
+ if (entry.type === 'tool_call') {
59
+ const toolCalls = [];
60
+ while (i < entries.length) {
61
+ const tc = entries[i];
62
+ if (!tc || tc.type !== 'tool_call')
63
+ break;
64
+ const id = typeof tc.data?.toolCallId === 'string' ? tc.data.toolCallId : `tc-${tc.id}`;
65
+ toolCalls.push({
66
+ id,
67
+ name: typeof tc.data?.tool === 'string' ? tc.data.tool : 'unknown',
68
+ input: tc.data?.input,
69
+ });
70
+ i += 1;
71
+ }
72
+ messages.push({ role: 'assistant', content: '', toolCalls });
73
+ continue;
74
+ }
75
+ const message = entryToModelMessage(entry);
76
+ if (message)
77
+ messages.push(message);
78
+ i += 1;
79
+ }
80
+ return messages;
81
+ }
82
+ }
83
+ export function buildModelMessagesFromHistory(data, role) {
84
+ return SessionHistory.fromData(data).buildModelMessages(role);
85
+ }
86
+ function entryToModelMessage(entry) {
87
+ switch (entry.type) {
88
+ case 'compaction': {
89
+ const summary = typeof entry.data?.summary === 'string' ? entry.data.summary : 'Previous context was compacted.';
90
+ return { role: 'user', content: `[Context Summary]\n\n${summary}` };
91
+ }
92
+ case 'user_prompt': {
93
+ const text = typeof entry.data?.text === 'string' ? entry.data.text : undefined;
94
+ return text ? { role: 'user', content: text } : undefined;
95
+ }
96
+ case 'assistant_message': {
97
+ const text = typeof entry.data?.text === 'string' ? entry.data.text : undefined;
98
+ return text ? { role: 'assistant', content: text } : undefined;
99
+ }
100
+ case 'tool_call': {
101
+ // Handled by grouping in buildModelMessages; skip individual entries
102
+ return undefined;
103
+ }
104
+ case 'tool_result': {
105
+ const tool = typeof entry.data?.tool === 'string' ? entry.data.tool : 'tool';
106
+ const output = entry.data?.output;
107
+ const toolCallId = typeof entry.data?.toolCallId === 'string' ? entry.data.toolCallId : undefined;
108
+ return { role: 'tool', name: tool, content: JSON.stringify(output ?? null), ...(toolCallId ? { toolCallId } : {}) };
109
+ }
110
+ case 'error': {
111
+ const error = typeof entry.data?.error === 'string' ? entry.data.error : undefined;
112
+ return error ? { role: 'user', content: `[Error]\n\n${error}` } : undefined;
113
+ }
114
+ default:
115
+ return undefined;
116
+ }
117
+ }
118
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.js","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,yBAAyB,GAAG,yiBAAyiB,CAAC;AAEnlB,MAAM,OAAO,cAAc;IACR,OAAO,CAAiB;IACxB,IAAI,CAA4B;IAChC,MAAM,CAAqB;IAE5C,YAAoB,OAAuB,EAAE,MAA0B;QACrE,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC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AAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;YAC7E,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC;YAClC,MAAM,UAAU,GAAG,OAAO,KAAK,CAAC,IAAI,EAAE,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;YAClG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;QACtH,CAAC;QACD,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,EAAE,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;YACnF,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAC9E,CAAC;QACD;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
@@ -0,0 +1,44 @@
1
+ export { init, StubFabricAgent } from './agent.js';
2
+ export { agent, defineAgent, getAgentDefinition } from './agent-definition.js';
3
+ export { resolveRuntimeMode, isStatelessRuntime, isInMemoryStore } from './runtime-mode.js';
4
+ export { evaluateContextBudget, estimateModelMessagesTokens, estimateSessionEntriesTokens, estimateTextTokens, isContextOverflowError } from './context-budget.js';
5
+ export { createFabricContext } from './context.js';
6
+ export { FabricError, isFabricError, toFabricError } from './error.js';
7
+ export { redactError, redactJson, redactText } from './redaction.js';
8
+ export { DEFAULT_HEADLESS_PREAMBLE, SessionHistory, buildModelMessagesFromHistory } from './history.js';
9
+ export { NativeLoopRuntime, defaultLoopRuntime } from './loop.js';
10
+ export { connectMcpServer, createMcpTools } from './mcp.js';
11
+ export { StdioMcpClient, createStdioMcpClient } from './mcp-stdio.js';
12
+ export { AnthropicModelProvider, AzureOpenAIModelProvider, BedrockModelProvider, CohereModelProvider, FallbackModelProvider, GeminiModelProvider, MockModelProvider, OpenAICompatibleModelProvider, ProviderHttpError, VertexAIModelProvider, defaultModelProvider, generateWithRuntime, toolsToModelSchemas, } from './model.js';
13
+ export { clampCommandTimeout, evaluateCommandPolicy, evaluateToolCallPolicy, } from './policy.js';
14
+ export { parseModelRef, resolveModelProvider } from './providers.js';
15
+ export { RESULT_END_DELIMITER, RESULT_START_DELIMITER, buildResultRetryPrompt, extractResultValue, validateResult } from './result.js';
16
+ export { StubFabricSession } from './session.js';
17
+ export { createRemoteSandboxEnv, createSandboxEnv, DockerSandboxEnv, EmptySandboxEnv, LocalSandboxEnv, UnimplementedSandboxEnv } from './sandbox.js';
18
+ export { inMemorySource, localDirectorySource, withFilesystemSources } from './filesystem-source.js';
19
+ export type { FilesystemEntry, FilesystemSource, MountedSource } from './filesystem-source.js';
20
+ export { SchemaValidationError, formatSchemaIssues, schema } from './schema.js';
21
+ export { emitOpenTelemetrySpan, openTelemetryExporter } from './otel.js';
22
+ export { consoleTelemetryExporter, entryToTelemetrySpan, eventToTelemetrySpan } from './telemetry.js';
23
+ export { InMemorySessionStore, NoopSessionStore, approvalStatesFromEntries, defaultSessionStore, noopSessionStore } from './store.js';
24
+ export { bashTool, createBuiltinTools, createCommandTools, createFileTools, defineCommand, defineTool, editFileTool, existsTool, globTool, grepTool, mkdirTool, readFileBufferTool, readFileTool, readdirTool, rmTool, secret, shellQuote, statTool, writeFileTool, } from './tools.js';
25
+ export type { ContextBudget, ContextBudgetOptions } from './context-budget.js';
26
+ export type { FabricErrorCode, FabricErrorOptions } from './error.js';
27
+ export type { RedactionOptions } from './redaction.js';
28
+ export type { ApprovalRisk, CapabilityPolicy, CommandPolicy, FilesystemPolicy, PolicyDecision, ToolPolicy } from './policy.js';
29
+ export type { ModelConfig, ParsedModelRef, ProviderSettings, ProvidersConfig, ResolveModelProviderOptions, ResolvedModelProvider } from './providers.js';
30
+ export type { AgentDefinition, AgentTriggers, DefineAgentOptions, DefinedAgent } from './agent-definition.js';
31
+ export type { RuntimeModeResolution } from './runtime-mode.js';
32
+ export type { JsonSchemaObject, Schema, SchemaIssue } from './schema.js';
33
+ export type { AgentLoopRuntime, PromptRunInput, PromptRunResult, } from './loop.js';
34
+ export type { CreateMcpToolsOptions, McpClientLike, McpServerConnection, McpServerOptions, McpToolDescriptor, McpTransport } from './mcp.js';
35
+ export type { OpenTelemetryExporterOptions } from './otel.js';
36
+ export type { TelemetryExporter, TelemetrySpan } from './telemetry.js';
37
+ export type { StdioMcpClientOptions } from './mcp-stdio.js';
38
+ export type { ModelAttemptEvent, ModelMessage, ModelMessageRole, ModelProvider, ModelRequest, ModelResponse, ModelRuntimeOptions, ModelToolCall, ModelToolSchema, ModelUsage, AnthropicProviderOptions, AzureOpenAIProviderOptions, BedrockProviderOptions, CohereProviderOptions, FallbackModelProviderOptions, GeminiProviderOptions, OpenAICompatibleProviderOptions, VertexAIProviderOptions, } from './model.js';
39
+ export type { FabricSession } from './session.js';
40
+ export { pruneSnapshots } from './sandbox.js';
41
+ export type { DockerSandboxOptions, FileStat, LocalSandboxOptions, RemoteSandboxApi, RemoteSandboxOptions, SandboxAdapterDescriptor, SandboxCapabilities, SandboxEnv, SandboxExecOptions, SandboxFactory, SandboxFactoryOptions, SandboxSnapshot, SnapshotPruneOptions, SnapshotPruneResult, } from './sandbox.js';
42
+ export type { ActorIdentity, AgentInit, ApprovalCallback, ApprovalDecision, ApprovalOptions, ApprovalRequest, ApprovalResponse, ApprovalState, ApprovalStateStatus, ApprovalUnavailableStrategy, ApprovalVote, ArtifactCreateOptions, ArtifactRef, AutonomyMode, AutonomyOptions, CheckpointCreateOptions, CheckpointRestoreOptions, CheckpointResult, CompactionOptions, CompactionResult, FabricActor, FabricAgent, FabricContext, FabricEvent, FabricEventCallback, FabricEventType, FabricRuntime, JsonObject, JsonPrimitive, JsonValue, CredentialMissingStrategy, MissingInputStrategy, PromptOptions, ResultExtractionOptions, ResultValidator, Role, SandboxBackend, SessionData, SessionEntry, SessionEntryType, SessionOptions, SessionStore, ShellOptions, ShellResult, Skill, SkillOptions, TaskOptions, } from './types.js';
43
+ export type { BashInput, BuiltinFileTool, BuiltinTool, Command, CommandEnvValue, CommandToolInput, CommandToolOptions, EditInput, ExistsInput, GlobInput, GrepInput, GrepMatch, MkdirInput, ReadFileBufferInput, ReadFileInput, ReaddirInput, RmInput, SecretRef, StatInput, ToolCall, ToolCallResult, ToolContext, ToolDef, ToolEffect, WriteFileInput, } from './tools.js';
44
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACnK,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,yBAAy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,cAAc,EACd,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,KAAK,EACL,YAAY,EACZ,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,SAAS,EACT,eAAe,EACf,WAAW,EACX,OAAO,EACP,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,SAAS,EACT,SAAS,EACT,QAAQ,EACR,cAAc,EACd,WAAW,EACX,OAAO,EACP,UAAU,EACV,cAAc,GACf,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ export { init, StubFabricAgent } from './agent.js';
2
+ export { agent, defineAgent, getAgentDefinition } from './agent-definition.js';
3
+ export { resolveRuntimeMode, isStatelessRuntime, isInMemoryStore } from './runtime-mode.js';
4
+ export { evaluateContextBudget, estimateModelMessagesTokens, estimateSessionEntriesTokens, estimateTextTokens, isContextOverflowError } from './context-budget.js';
5
+ export { createFabricContext } from './context.js';
6
+ export { FabricError, isFabricError, toFabricError } from './error.js';
7
+ export { redactError, redactJson, redactText } from './redaction.js';
8
+ export { DEFAULT_HEADLESS_PREAMBLE, SessionHistory, buildModelMessagesFromHistory } from './history.js';
9
+ export { NativeLoopRuntime, defaultLoopRuntime } from './loop.js';
10
+ export { connectMcpServer, createMcpTools } from './mcp.js';
11
+ export { StdioMcpClient, createStdioMcpClient } from './mcp-stdio.js';
12
+ export { AnthropicModelProvider, AzureOpenAIModelProvider, BedrockModelProvider, CohereModelProvider, FallbackModelProvider, GeminiModelProvider, MockModelProvider, OpenAICompatibleModelProvider, ProviderHttpError, VertexAIModelProvider, defaultModelProvider, generateWithRuntime, toolsToModelSchemas, } from './model.js';
13
+ export { clampCommandTimeout, evaluateCommandPolicy, evaluateToolCallPolicy, } from './policy.js';
14
+ export { parseModelRef, resolveModelProvider } from './providers.js';
15
+ export { RESULT_END_DELIMITER, RESULT_START_DELIMITER, buildResultRetryPrompt, extractResultValue, validateResult } from './result.js';
16
+ export { StubFabricSession } from './session.js';
17
+ export { createRemoteSandboxEnv, createSandboxEnv, DockerSandboxEnv, EmptySandboxEnv, LocalSandboxEnv, UnimplementedSandboxEnv } from './sandbox.js';
18
+ export { inMemorySource, localDirectorySource, withFilesystemSources } from './filesystem-source.js';
19
+ export { SchemaValidationError, formatSchemaIssues, schema } from './schema.js';
20
+ export { emitOpenTelemetrySpan, openTelemetryExporter } from './otel.js';
21
+ export { consoleTelemetryExporter, entryToTelemetrySpan, eventToTelemetrySpan } from './telemetry.js';
22
+ export { InMemorySessionStore, NoopSessionStore, approvalStatesFromEntries, defaultSessionStore, noopSessionStore } from './store.js';
23
+ export { bashTool, createBuiltinTools, createCommandTools, createFileTools, defineCommand, defineTool, editFileTool, existsTool, globTool, grepTool, mkdirTool, readFileBufferTool, readFileTool, readdirTool, rmTool, secret, shellQuote, statTool, writeFileTool, } from './tools.js';
24
+ export { pruneSnapshots } from './sandbox.js';
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACnK,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,aAAa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M,WAAW,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtG,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACtI,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,UAAU,EACV,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,MAAM,EACN,MAAM,EACN,UAAU,EACV,QAAQ,EACR,aAAa,GACd,MAAM,YAAY,CAAC;AAwCpB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
package/dist/lite.d.ts ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @fabric-harness/sdk/lite — minimal headless surface.
3
+ *
4
+ * This entry point re-exports the small subset of the SDK needed to write
5
+ * a stateless / headless agent in ~10 lines. Nothing here pulls Temporal,
6
+ * persistent stores, telemetry exporters, or backend-specific code into
7
+ * the import graph. Use this when bundling for Cloudflare Workers, Vercel
8
+ * Edge, AWS Lambda, or any environment where you want the smallest
9
+ * possible import footprint.
10
+ *
11
+ * For the full surface (typed I/O schemas, capability policy,
12
+ * artifacts, durable runtime, custom session stores), import from
13
+ * `@fabric-harness/sdk` directly.
14
+ *
15
+ * ```ts
16
+ * import { defineAgent } from '@fabric-harness/sdk/lite';
17
+ *
18
+ * export default defineAgent(async ({ init, payload }) => {
19
+ * const session = await (await init({
20
+ * model: 'anthropic/claude-sonnet-4-6',
21
+ * runtime: 'stateless',
22
+ * })).session();
23
+ * return { reply: (await session.prompt(String(payload?.message ?? ''))).text };
24
+ * });
25
+ * ```
26
+ */
27
+ export { init, StubFabricAgent } from './agent.js';
28
+ export { agent, defineAgent, getAgentDefinition } from './agent-definition.js';
29
+ export { createFabricContext } from './context.js';
30
+ export { FabricError, isFabricError, toFabricError } from './error.js';
31
+ export { schema, SchemaValidationError } from './schema.js';
32
+ export { defineCommand, defineTool, secret, shellQuote } from './tools.js';
33
+ export { createSandboxEnv, EmptySandboxEnv, LocalSandboxEnv } from './sandbox.js';
34
+ export { inMemorySource, localDirectorySource, withFilesystemSources } from './filesystem-source.js';
35
+ export type { FilesystemEntry, FilesystemSource, MountedSource } from './filesystem-source.js';
36
+ export { resolveRuntimeMode, isStatelessRuntime } from './runtime-mode.js';
37
+ export { noopSessionStore, NoopSessionStore } from './store.js';
38
+ export { connectMcpServer } from './mcp.js';
39
+ export type { AgentDefinition, AgentTriggers, DefineAgentOptions, DefinedAgent } from './agent-definition.js';
40
+ export type { Schema, SchemaIssue, JsonSchemaObject } from './schema.js';
41
+ export type { Command, CommandEnvValue, SecretRef, ToolDef, } from './tools.js';
42
+ export type { AgentInit, FabricAgent, FabricContext, FabricRuntime, JsonObject, JsonValue, PromptOptions, Role, SandboxBackend, SessionOptions, ShellOptions, ShellResult, Skill, SkillOptions, } from './types.js';
43
+ export type { FabricSession } from './session.js';
44
+ export type { SandboxEnv, SandboxFactory, SandboxFactoryOptions } from './sandbox.js';
45
+ export type { ModelConfig, ProviderSettings, ProvidersConfig } from './providers.js';
46
+ //# sourceMappingURL=lite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lite.d.ts","sourceRoot":"","sources":["../src/lite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,MAAM,E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harness/sdk/lite — minimal headless surface.
3
+ *
4
+ * This entry point re-exports the small subset of the SDK needed to write
5
+ * a stateless / headless agent in ~10 lines. Nothing here pulls Temporal,
6
+ * persistent stores, telemetry exporters, or backend-specific code into
7
+ * the import graph. Use this when bundling for Cloudflare Workers, Vercel
8
+ * Edge, AWS Lambda, or any environment where you want the smallest
9
+ * possible import footprint.
10
+ *
11
+ * For the full surface (typed I/O schemas, capability policy,
12
+ * artifacts, durable runtime, custom session stores), import from
13
+ * `@fabric-harness/sdk` directly.
14
+ *
15
+ * ```ts
16
+ * import { defineAgent } from '@fabric-harness/sdk/lite';
17
+ *
18
+ * export default defineAgent(async ({ init, payload }) => {
19
+ * const session = await (await init({
20
+ * model: 'anthropic/claude-sonnet-4-6',
21
+ * runtime: 'stateless',
22
+ * })).session();
23
+ * return { reply: (await session.prompt(String(payload?.message ?? ''))).text };
24
+ * });
25
+ * ```
26
+ */
27
+ export { init, StubFabricAgent } from './agent.js';
28
+ export { agent, defineAgent, getAgentDefinition } from './agent-definition.js';
29
+ export { createFabricContext } from './context.js';
30
+ export { FabricError, isFabricError, toFabricError } from './error.js';
31
+ export { schema, SchemaValidationError } from './schema.js';
32
+ export { defineCommand, defineTool, secret, shellQuote } from './tools.js';
33
+ export { createSandboxEnv, EmptySandboxEnv, LocalSandboxEnv } from './sandbox.js';
34
+ export { inMemorySource, localDirectorySource, withFilesystemSources } from './filesystem-source.js';
35
+ export { resolveRuntimeMode, isStatelessRuntime } from './runtime-mode.js';
36
+ export { noopSessionStore, NoopSessionStore } from './store.js';
37
+ export { connectMcpServer } from './mcp.js';
38
+ //# sourceMappingURL=lite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lite.js","sourceRoot":"","sources":["../src/lite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAErG,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
package/dist/loop.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ import type { ModelMessage, ModelProvider, ModelUsage } from './model.js';
2
+ import type { CapabilityPolicy } from './policy.js';
3
+ import type { SandboxEnv } from './sandbox.js';
4
+ import type { ToolCall, ToolCallResult, ToolDef } from './tools.js';
5
+ import type { FabricEvent, JsonObject, SessionEntry, SessionEntryType } from './types.js';
6
+ export interface AgentLoopRuntime {
7
+ readonly name: string;
8
+ runPrompt(input: PromptRunInput): Promise<PromptRunResult>;
9
+ }
10
+ export interface PromptRunInput {
11
+ sessionId: string;
12
+ text: string;
13
+ messages: ModelMessage[];
14
+ tools: Map<string, ToolDef>;
15
+ sandbox: SandboxEnv;
16
+ model?: string;
17
+ modelProvider?: ModelProvider;
18
+ toolCalls?: ToolCall[];
19
+ maxIterations?: number;
20
+ modelTimeoutMs?: number;
21
+ modelRetries?: number;
22
+ modelRetryDelayMs?: number;
23
+ signal?: AbortSignal;
24
+ policy?: CapabilityPolicy;
25
+ approvalTimeoutMs?: number;
26
+ executeToolCalls(calls: ToolCall[], policy?: CapabilityPolicy, approvalTimeoutMs?: number): Promise<ToolCallResult[]>;
27
+ recordEntry(type: SessionEntryType, data?: JsonObject): Promise<SessionEntry>;
28
+ emit(type: FabricEvent['type'], data?: JsonObject): Promise<void>;
29
+ }
30
+ export interface PromptRunResult {
31
+ text: string;
32
+ raw: unknown;
33
+ usage?: ModelUsage;
34
+ }
35
+ export declare class NativeLoopRuntime implements AgentLoopRuntime {
36
+ readonly name = "native";
37
+ runPrompt(input: PromptRunInput): Promise<PromptRunResult>;
38
+ private executeModelToolCalls;
39
+ }
40
+ export declare const defaultLoopRuntime: NativeLoopRuntime;
41
+ //# sourceMappingURL=loop.d.ts.map