@aexol/spectral 0.9.221 → 0.9.223

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 (166) hide show
  1. package/dist/agent/index.d.ts +20 -3
  2. package/dist/agent/index.d.ts.map +1 -1
  3. package/dist/agent/index.js +286 -80
  4. package/dist/extensions/aexol-backend-client.d.ts +85 -0
  5. package/dist/extensions/aexol-backend-client.d.ts.map +1 -0
  6. package/dist/extensions/aexol-backend-client.js +159 -0
  7. package/dist/extensions/aexol-mcp.d.ts +10 -6
  8. package/dist/extensions/aexol-mcp.d.ts.map +1 -1
  9. package/dist/extensions/aexol-mcp.js +21 -106
  10. package/dist/extensions/logic-trace-backend-draft.d.ts +68 -0
  11. package/dist/extensions/logic-trace-backend-draft.d.ts.map +1 -0
  12. package/dist/extensions/logic-trace-backend-draft.js +171 -0
  13. package/dist/extensions/logic-trace-validate.d.ts +33 -0
  14. package/dist/extensions/logic-trace-validate.d.ts.map +1 -0
  15. package/dist/extensions/logic-trace-validate.js +73 -0
  16. package/dist/extensions/logic-trace.d.ts +213 -0
  17. package/dist/extensions/logic-trace.d.ts.map +1 -0
  18. package/dist/extensions/logic-trace.js +1098 -0
  19. package/dist/generated/parser/lexer.d.ts +148 -0
  20. package/dist/generated/parser/lexer.d.ts.map +1 -0
  21. package/dist/generated/parser/lexer.js +877 -0
  22. package/dist/generated/parser/mod.d.ts +26 -0
  23. package/dist/generated/parser/mod.d.ts.map +1 -0
  24. package/dist/generated/parser/mod.js +30 -0
  25. package/dist/generated/parser/parser.d.ts +161 -0
  26. package/dist/generated/parser/parser.d.ts.map +1 -0
  27. package/dist/generated/parser/parser.js +754 -0
  28. package/dist/generated/parser/tokenizer.d.ts +107 -0
  29. package/dist/generated/parser/tokenizer.d.ts.map +1 -0
  30. package/dist/generated/parser/tokenizer.js +202 -0
  31. package/dist/generated/parser/validator.d.ts +45 -0
  32. package/dist/generated/parser/validator.d.ts.map +1 -0
  33. package/dist/generated/parser/validator.js +202 -0
  34. package/dist/generated/zeus/const.d.ts.map +1 -1
  35. package/dist/generated/zeus/const.js +4 -170
  36. package/dist/generated/zeus/index.d.ts +8 -873
  37. package/dist/generated/zeus/index.d.ts.map +1 -1
  38. package/dist/generated/zeus/index.js +0 -7
  39. package/dist/mcp/ui-stream-types.d.ts +2 -2
  40. package/dist/memory/tools/share-project-observation.js +1 -1
  41. package/dist/memory/tools/write-project-observation.d.ts.map +1 -1
  42. package/dist/memory/tools/write-project-observation.js +4 -3
  43. package/dist/sdk/agent-core/agent-loop.d.ts.map +1 -1
  44. package/dist/sdk/agent-core/agent-loop.js +2 -4
  45. package/dist/sdk/agent-core/harness/types.d.ts +0 -1
  46. package/dist/sdk/agent-core/harness/types.d.ts.map +1 -1
  47. package/dist/sdk/agent-core/index.d.ts +0 -8
  48. package/dist/sdk/agent-core/index.d.ts.map +1 -1
  49. package/dist/sdk/agent-core/index.js +0 -9
  50. package/dist/sdk/ai/index.d.ts +1 -0
  51. package/dist/sdk/ai/index.d.ts.map +1 -1
  52. package/dist/sdk/ai/index.js +1 -0
  53. package/dist/sdk/ai/utils/transient-error.d.ts +28 -0
  54. package/dist/sdk/ai/utils/transient-error.d.ts.map +1 -0
  55. package/dist/sdk/ai/utils/transient-error.js +55 -0
  56. package/dist/sdk/coding-agent/core/agent-session.d.ts.map +1 -1
  57. package/dist/sdk/coding-agent/core/agent-session.js +7 -3
  58. package/dist/sdk/coding-agent/core/extensions/index.d.ts +1 -1
  59. package/dist/sdk/coding-agent/core/extensions/index.d.ts.map +1 -1
  60. package/dist/sdk/coding-agent/core/extensions/native-extensions.js +2 -2
  61. package/dist/sdk/coding-agent/core/extensions/types.d.ts +20 -1
  62. package/dist/sdk/coding-agent/core/extensions/types.d.ts.map +1 -1
  63. package/dist/sdk/coding-agent/core/tools/tool-definition-wrapper.d.ts +9 -4
  64. package/dist/sdk/coding-agent/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  65. package/dist/sdk/coding-agent/core/tools/tool-definition-wrapper.js +15 -2
  66. package/dist/sdk/coding-agent/index.d.ts +1 -1
  67. package/dist/sdk/coding-agent/index.d.ts.map +1 -1
  68. package/dist/server/agent-bridge/headless-ui.d.ts +20 -0
  69. package/dist/server/agent-bridge/headless-ui.d.ts.map +1 -0
  70. package/dist/server/agent-bridge/headless-ui.js +85 -0
  71. package/dist/server/agent-bridge/pricing.d.ts +54 -0
  72. package/dist/server/agent-bridge/pricing.d.ts.map +1 -0
  73. package/dist/server/agent-bridge/pricing.js +226 -0
  74. package/dist/server/agent-bridge/rehydrate.d.ts +35 -0
  75. package/dist/server/agent-bridge/rehydrate.d.ts.map +1 -0
  76. package/dist/server/agent-bridge/rehydrate.js +122 -0
  77. package/dist/server/agent-bridge/synthetic-model.d.ts +27 -0
  78. package/dist/server/agent-bridge/synthetic-model.d.ts.map +1 -0
  79. package/dist/server/agent-bridge/synthetic-model.js +92 -0
  80. package/dist/server/agent-bridge.d.ts +17 -1
  81. package/dist/server/agent-bridge.d.ts.map +1 -1
  82. package/dist/server/agent-bridge.js +81 -496
  83. package/dist/server/error-humanizer.d.ts +11 -3
  84. package/dist/server/error-humanizer.d.ts.map +1 -1
  85. package/dist/server/error-humanizer.js +11 -3
  86. package/dist/server/session-stream/compaction-events.d.ts +13 -0
  87. package/dist/server/session-stream/compaction-events.d.ts.map +1 -0
  88. package/dist/server/session-stream/compaction-events.js +32 -0
  89. package/dist/server/session-stream/history-prune.d.ts +35 -0
  90. package/dist/server/session-stream/history-prune.d.ts.map +1 -0
  91. package/dist/server/session-stream/history-prune.js +182 -0
  92. package/dist/server/session-stream/memory.d.ts +48 -0
  93. package/dist/server/session-stream/memory.d.ts.map +1 -0
  94. package/dist/server/session-stream/memory.js +136 -0
  95. package/dist/server/session-stream/replay-tail.d.ts +4 -0
  96. package/dist/server/session-stream/replay-tail.d.ts.map +1 -0
  97. package/dist/server/session-stream/replay-tail.js +39 -0
  98. package/dist/server/session-stream/turn-events.d.ts +33 -0
  99. package/dist/server/session-stream/turn-events.d.ts.map +1 -0
  100. package/dist/server/session-stream/turn-events.js +65 -0
  101. package/dist/server/session-stream/turn-silence.d.ts +8 -0
  102. package/dist/server/session-stream/turn-silence.d.ts.map +1 -0
  103. package/dist/server/session-stream/turn-silence.js +72 -0
  104. package/dist/server/session-stream.d.ts +137 -36
  105. package/dist/server/session-stream.d.ts.map +1 -1
  106. package/dist/server/session-stream.js +18 -509
  107. package/dist/server/storage/observation-ranking.d.ts +14 -0
  108. package/dist/server/storage/observation-ranking.d.ts.map +1 -0
  109. package/dist/server/storage/observation-ranking.js +37 -0
  110. package/dist/server/storage/preflight.d.ts +20 -0
  111. package/dist/server/storage/preflight.d.ts.map +1 -0
  112. package/dist/server/storage/preflight.js +22 -0
  113. package/dist/server/storage/project-binding.d.ts +5 -0
  114. package/dist/server/storage/project-binding.d.ts.map +1 -0
  115. package/dist/server/storage/project-binding.js +32 -0
  116. package/dist/server/storage/rows.d.ts +104 -0
  117. package/dist/server/storage/rows.d.ts.map +1 -0
  118. package/dist/server/storage/rows.js +2 -0
  119. package/dist/server/storage/schema.d.ts +20 -0
  120. package/dist/server/storage/schema.d.ts.map +1 -0
  121. package/dist/server/storage/schema.js +134 -0
  122. package/dist/server/storage/types.d.ts +66 -0
  123. package/dist/server/storage/types.d.ts.map +1 -0
  124. package/dist/server/storage/types.js +1 -0
  125. package/dist/server/storage.d.ts +7 -94
  126. package/dist/server/storage.d.ts.map +1 -1
  127. package/dist/server/storage.js +6 -224
  128. package/dist/server/wire.d.ts +19 -0
  129. package/dist/server/wire.d.ts.map +1 -1
  130. package/package.json +2 -1
  131. package/dist/sdk/agent-core/harness/agent-harness.d.ts +0 -92
  132. package/dist/sdk/agent-core/harness/agent-harness.d.ts.map +0 -1
  133. package/dist/sdk/agent-core/harness/agent-harness.js +0 -899
  134. package/dist/sdk/agent-core/harness/env/nodejs.d.ts +0 -51
  135. package/dist/sdk/agent-core/harness/env/nodejs.d.ts.map +0 -1
  136. package/dist/sdk/agent-core/harness/env/nodejs.js +0 -485
  137. package/dist/sdk/agent-core/harness/prompt-templates.d.ts +0 -48
  138. package/dist/sdk/agent-core/harness/prompt-templates.d.ts.map +0 -1
  139. package/dist/sdk/agent-core/harness/prompt-templates.js +0 -229
  140. package/dist/sdk/agent-core/harness/session/jsonl-repo.d.ts +0 -26
  141. package/dist/sdk/agent-core/harness/session/jsonl-repo.d.ts.map +0 -1
  142. package/dist/sdk/agent-core/harness/session/jsonl-repo.js +0 -100
  143. package/dist/sdk/agent-core/harness/session/jsonl-storage.d.ts +0 -33
  144. package/dist/sdk/agent-core/harness/session/jsonl-storage.d.ts.map +0 -1
  145. package/dist/sdk/agent-core/harness/session/jsonl-storage.js +0 -230
  146. package/dist/sdk/agent-core/harness/session/memory-repo.d.ts +0 -18
  147. package/dist/sdk/agent-core/harness/session/memory-repo.d.ts.map +0 -1
  148. package/dist/sdk/agent-core/harness/session/memory-repo.js +0 -41
  149. package/dist/sdk/agent-core/harness/session/memory-storage.d.ts +0 -25
  150. package/dist/sdk/agent-core/harness/session/memory-storage.d.ts.map +0 -1
  151. package/dist/sdk/agent-core/harness/session/memory-storage.js +0 -113
  152. package/dist/sdk/agent-core/harness/session/repo-utils.d.ts +0 -11
  153. package/dist/sdk/agent-core/harness/session/repo-utils.d.ts.map +0 -1
  154. package/dist/sdk/agent-core/harness/session/repo-utils.js +0 -38
  155. package/dist/sdk/agent-core/harness/skills.d.ts +0 -44
  156. package/dist/sdk/agent-core/harness/skills.d.ts.map +0 -1
  157. package/dist/sdk/agent-core/harness/skills.js +0 -310
  158. package/dist/sdk/agent-core/harness/utils/shell-output.d.ts +0 -14
  159. package/dist/sdk/agent-core/harness/utils/shell-output.d.ts.map +0 -1
  160. package/dist/sdk/agent-core/harness/utils/shell-output.js +0 -125
  161. package/dist/sdk/agent-core/node.d.ts +0 -3
  162. package/dist/sdk/agent-core/node.d.ts.map +0 -1
  163. package/dist/sdk/agent-core/node.js +0 -2
  164. package/dist/sdk/agent-core/proxy.d.ts +0 -69
  165. package/dist/sdk/agent-core/proxy.d.ts.map +0 -1
  166. package/dist/sdk/agent-core/proxy.js +0 -297
@@ -1,41 +0,0 @@
1
- import { SessionError } from "../types.js";
2
- import { InMemorySessionStorage } from "./memory-storage.js";
3
- import { createSessionId, createTimestamp, getEntriesToFork, toSession } from "./repo-utils.js";
4
- export class InMemorySessionRepo {
5
- sessions = new Map();
6
- async create(options = {}) {
7
- const metadata = {
8
- id: options.id ?? createSessionId(),
9
- createdAt: createTimestamp(),
10
- };
11
- const storage = new InMemorySessionStorage({ metadata });
12
- const session = toSession(storage);
13
- this.sessions.set(metadata.id, session);
14
- return session;
15
- }
16
- async open(metadata) {
17
- const session = this.sessions.get(metadata.id);
18
- if (!session) {
19
- throw new SessionError("not_found", `Session not found: ${metadata.id}`);
20
- }
21
- return session;
22
- }
23
- async list() {
24
- return Promise.all([...this.sessions.values()].map((session) => session.getMetadata()));
25
- }
26
- async delete(metadata) {
27
- this.sessions.delete(metadata.id);
28
- }
29
- async fork(sourceMetadata, options) {
30
- const source = await this.open(sourceMetadata);
31
- const forkedEntries = await getEntriesToFork(source.getStorage(), options);
32
- const metadata = {
33
- id: options.id ?? createSessionId(),
34
- createdAt: createTimestamp(),
35
- };
36
- const storage = new InMemorySessionStorage({ metadata, entries: forkedEntries });
37
- const session = toSession(storage);
38
- this.sessions.set(metadata.id, session);
39
- return session;
40
- }
41
- }
@@ -1,25 +0,0 @@
1
- import { type SessionMetadata, type SessionStorage, type SessionTreeEntry } from "../types.js";
2
- export declare class InMemorySessionStorage<TMetadata extends SessionMetadata = SessionMetadata> implements SessionStorage<TMetadata> {
3
- private readonly metadata;
4
- private entries;
5
- private byId;
6
- private labelsById;
7
- private leafId;
8
- constructor(options?: {
9
- entries?: SessionTreeEntry[];
10
- metadata?: TMetadata;
11
- });
12
- getMetadata(): Promise<TMetadata>;
13
- getLeafId(): Promise<string | null>;
14
- setLeafId(leafId: string | null): Promise<void>;
15
- createEntryId(): Promise<string>;
16
- appendEntry(entry: SessionTreeEntry): Promise<void>;
17
- getEntry(id: string): Promise<SessionTreeEntry | undefined>;
18
- findEntries<TType extends SessionTreeEntry["type"]>(type: TType): Promise<Array<Extract<SessionTreeEntry, {
19
- type: TType;
20
- }>>>;
21
- getLabel(id: string): Promise<string | undefined>;
22
- getPathToRoot(leafId: string | null): Promise<SessionTreeEntry[]>;
23
- getEntries(): Promise<SessionTreeEntry[]>;
24
- }
25
- //# sourceMappingURL=memory-storage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory-storage.d.ts","sourceRoot":"","sources":["../../../../../src/sdk/agent-core/harness/session/memory-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,MAAM,aAAa,CAAC;AAiCrB,qBAAa,sBAAsB,CAAC,SAAS,SAAS,eAAe,GAAG,eAAe,CACtF,YAAW,cAAc,CAAC,SAAS,CAAC;IAEpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAY;IACrC,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,IAAI,CAAgC;IAC5C,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,MAAM,CAAgB;gBAElB,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;QAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;KAAE;IAYtE,WAAW,IAAI,OAAO,CAAC,SAAS,CAAC;IAIjC,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAOnC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB/C,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAIhC,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAOnD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAI3D,WAAW,CAAC,KAAK,SAAS,gBAAgB,CAAC,MAAM,CAAC,EACvD,IAAI,EAAE,KAAK,GACT,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE;QAAE,IAAI,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC,CAAC;IAIvD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIjD,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAejE,UAAU,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;CAG/C"}
@@ -1,113 +0,0 @@
1
- import { SessionError, } from "../types.js";
2
- import { uuidv7 } from "./uuid.js";
3
- function updateLabelCache(labelsById, entry) {
4
- if (entry.type !== "label")
5
- return;
6
- const label = entry.label?.trim();
7
- if (label) {
8
- labelsById.set(entry.targetId, label);
9
- }
10
- else {
11
- labelsById.delete(entry.targetId);
12
- }
13
- }
14
- function buildLabelsById(entries) {
15
- const labelsById = new Map();
16
- for (const entry of entries) {
17
- updateLabelCache(labelsById, entry);
18
- }
19
- return labelsById;
20
- }
21
- function generateEntryId(byId) {
22
- for (let i = 0; i < 100; i++) {
23
- const id = uuidv7().slice(0, 8);
24
- if (!byId.has(id))
25
- return id;
26
- }
27
- return uuidv7();
28
- }
29
- function leafIdAfterEntry(entry) {
30
- return entry.type === "leaf" ? entry.targetId : entry.id;
31
- }
32
- export class InMemorySessionStorage {
33
- metadata;
34
- entries;
35
- byId;
36
- labelsById;
37
- leafId;
38
- constructor(options) {
39
- this.entries = options?.entries ? [...options.entries] : [];
40
- this.byId = new Map(this.entries.map((entry) => [entry.id, entry]));
41
- this.labelsById = buildLabelsById(this.entries);
42
- this.leafId = null;
43
- for (const entry of this.entries)
44
- this.leafId = leafIdAfterEntry(entry);
45
- if (this.leafId !== null && !this.byId.has(this.leafId)) {
46
- throw new SessionError("invalid_session", `Entry ${this.leafId} not found`);
47
- }
48
- this.metadata = options?.metadata ?? { id: uuidv7(), createdAt: new Date().toISOString() };
49
- }
50
- async getMetadata() {
51
- return this.metadata;
52
- }
53
- async getLeafId() {
54
- if (this.leafId !== null && !this.byId.has(this.leafId)) {
55
- throw new SessionError("invalid_session", `Entry ${this.leafId} not found`);
56
- }
57
- return this.leafId;
58
- }
59
- async setLeafId(leafId) {
60
- if (leafId !== null && !this.byId.has(leafId)) {
61
- throw new SessionError("not_found", `Entry ${leafId} not found`);
62
- }
63
- const entry = {
64
- type: "leaf",
65
- id: generateEntryId(this.byId),
66
- parentId: this.leafId,
67
- timestamp: new Date().toISOString(),
68
- targetId: leafId,
69
- };
70
- this.entries.push(entry);
71
- this.byId.set(entry.id, entry);
72
- this.leafId = leafId;
73
- }
74
- async createEntryId() {
75
- return generateEntryId(this.byId);
76
- }
77
- async appendEntry(entry) {
78
- this.entries.push(entry);
79
- this.byId.set(entry.id, entry);
80
- updateLabelCache(this.labelsById, entry);
81
- this.leafId = leafIdAfterEntry(entry);
82
- }
83
- async getEntry(id) {
84
- return this.byId.get(id);
85
- }
86
- async findEntries(type) {
87
- return this.entries.filter((entry) => entry.type === type);
88
- }
89
- async getLabel(id) {
90
- return this.labelsById.get(id);
91
- }
92
- async getPathToRoot(leafId) {
93
- if (leafId === null)
94
- return [];
95
- const path = [];
96
- let current = this.byId.get(leafId);
97
- if (!current)
98
- throw new SessionError("not_found", `Entry ${leafId} not found`);
99
- while (current) {
100
- path.unshift(current);
101
- if (!current.parentId)
102
- break;
103
- const parent = this.byId.get(current.parentId);
104
- if (!parent)
105
- throw new SessionError("invalid_session", `Entry ${current.parentId} not found`);
106
- current = parent;
107
- }
108
- return path;
109
- }
110
- async getEntries() {
111
- return [...this.entries];
112
- }
113
- }
@@ -1,11 +0,0 @@
1
- import { type FileError, type Result, type SessionMetadata, type SessionStorage, type SessionTreeEntry } from "../types.js";
2
- import { Session } from "./session.js";
3
- export declare function createSessionId(): string;
4
- export declare function createTimestamp(): string;
5
- export declare function toSession<TMetadata extends SessionMetadata>(storage: SessionStorage<TMetadata>): Session<TMetadata>;
6
- export declare function getFileSystemResultOrThrow<TValue>(result: Result<TValue, FileError>, message: string): TValue;
7
- export declare function getEntriesToFork(storage: SessionStorage, options: {
8
- entryId?: string;
9
- position?: "before" | "at";
10
- }): Promise<SessionTreeEntry[]>;
11
- //# sourceMappingURL=repo-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"repo-utils.d.ts","sourceRoot":"","sources":["../../../../../src/sdk/agent-core/harness/session/repo-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,SAAS,EACd,KAAK,MAAM,EAEX,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,wBAAgB,SAAS,CAAC,SAAS,SAAS,eAAe,EAAE,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAEnH;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAM7G;AAED,wBAAsB,gBAAgB,CACrC,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAA;CAAE,GACvD,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAgB7B"}
@@ -1,38 +0,0 @@
1
- import { SessionError, } from "../types.js";
2
- import { Session } from "./session.js";
3
- import { uuidv7 } from "./uuid.js";
4
- export function createSessionId() {
5
- return uuidv7();
6
- }
7
- export function createTimestamp() {
8
- return new Date().toISOString();
9
- }
10
- export function toSession(storage) {
11
- return new Session(storage);
12
- }
13
- export function getFileSystemResultOrThrow(result, message) {
14
- if (!result.ok) {
15
- const code = result.error.code === "not_found" ? "not_found" : "storage";
16
- throw new SessionError(code, `${message}: ${result.error.message}`, result.error);
17
- }
18
- return result.value;
19
- }
20
- export async function getEntriesToFork(storage, options) {
21
- if (!options.entryId)
22
- return storage.getEntries();
23
- const target = await storage.getEntry(options.entryId);
24
- if (!target) {
25
- throw new SessionError("invalid_fork_target", `Entry ${options.entryId} not found`);
26
- }
27
- let effectiveLeafId;
28
- if ((options.position ?? "before") === "at") {
29
- effectiveLeafId = target.id;
30
- }
31
- else {
32
- if (target.type !== "message" || target.message.role !== "user") {
33
- throw new SessionError("invalid_fork_target", `Entry ${options.entryId} is not a user message`);
34
- }
35
- effectiveLeafId = target.parentId;
36
- }
37
- return storage.getPathToRoot(effectiveLeafId);
38
- }
@@ -1,44 +0,0 @@
1
- import { type ExecutionEnv, type Skill } from "./types.js";
2
- export type SkillDiagnosticCode = "file_info_failed" | "list_failed" | "read_failed" | "parse_failed" | "invalid_metadata";
3
- /** Warning produced while loading skills. */
4
- export interface SkillDiagnostic {
5
- /** Diagnostic severity. Currently only warnings are emitted. */
6
- type: "warning";
7
- /** Stable diagnostic code. */
8
- code: SkillDiagnosticCode;
9
- /** Human-readable diagnostic message. */
10
- message: string;
11
- /** Path associated with the diagnostic. */
12
- path: string;
13
- }
14
- /** Format a skill invocation prompt, optionally appending additional user instructions. */
15
- export declare function formatSkillInvocation(skill: Skill, additionalInstructions?: string): string;
16
- /**
17
- * Load skills from one or more directories.
18
- *
19
- * Traverses directories recursively, loads `SKILL.md` files, loads direct root `.md` files as skills, honors ignore files,
20
- * and returns diagnostics for invalid skill files. Missing input directories are skipped.
21
- */
22
- export declare function loadSkills(env: ExecutionEnv, dirs: string | string[]): Promise<{
23
- skills: Skill[];
24
- diagnostics: SkillDiagnostic[];
25
- }>;
26
- /**
27
- * Load skills from source-tagged directories.
28
- *
29
- * Source values are preserved exactly and attached to every loaded skill and diagnostic. The agent package does not
30
- * interpret source values; applications define their own provenance shape.
31
- */
32
- export declare function loadSourcedSkills<TSource, TSkill extends Skill = Skill>(env: ExecutionEnv, inputs: Array<{
33
- path: string;
34
- source: TSource;
35
- }>, mapSkill?: (skill: Skill, source: TSource) => TSkill): Promise<{
36
- skills: Array<{
37
- skill: TSkill;
38
- source: TSource;
39
- }>;
40
- diagnostics: Array<SkillDiagnostic & {
41
- source: TSource;
42
- }>;
43
- }>;
44
- //# sourceMappingURL=skills.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../../../src/sdk/agent-core/harness/skills.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAA8B,KAAK,KAAK,EAAW,MAAM,YAAY,CAAC;AAQhG,MAAM,MAAM,mBAAmB,GAC5B,kBAAkB,GAClB,aAAa,GACb,aAAa,GACb,cAAc,GACd,kBAAkB,CAAC;AAEtB,6CAA6C;AAC7C,MAAM,WAAW,eAAe;IAC/B,gEAAgE;IAChE,IAAI,EAAE,SAAS,CAAC;IAChB,8BAA8B;IAC9B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;CACb;AASD,2FAA2F;AAC3F,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,KAAK,EAAE,sBAAsB,CAAC,EAAE,MAAM,GAAG,MAAM,CAG3F;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAC/B,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GACrB,OAAO,CAAC;IAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAAC,WAAW,EAAE,eAAe,EAAE,CAAA;CAAE,CAAC,CAuB9D;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,SAAS,KAAK,GAAG,KAAK,EAC5E,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,EAChD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,KAAK,MAAM,GAClD,OAAO,CAAC;IACV,MAAM,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAClD,WAAW,EAAE,KAAK,CAAC,eAAe,GAAG;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAC1D,CAAC,CAWD"}
@@ -1,310 +0,0 @@
1
- import ignore from "ignore";
2
- import { parse } from "yaml";
3
- import { toError } from "./types.js";
4
- const MAX_NAME_LENGTH = 64;
5
- const MAX_DESCRIPTION_LENGTH = 1024;
6
- const IGNORE_FILE_NAMES = [".gitignore", ".ignore", ".fdignore"];
7
- /** Format a skill invocation prompt, optionally appending additional user instructions. */
8
- export function formatSkillInvocation(skill, additionalInstructions) {
9
- const skillBlock = `<skill name="${skill.name}" location="${skill.filePath}">\nReferences are relative to ${dirnameEnvPath(skill.filePath)}.\n\n${skill.content}\n</skill>`;
10
- return additionalInstructions ? `${skillBlock}\n\n${additionalInstructions}` : skillBlock;
11
- }
12
- /**
13
- * Load skills from one or more directories.
14
- *
15
- * Traverses directories recursively, loads `SKILL.md` files, loads direct root `.md` files as skills, honors ignore files,
16
- * and returns diagnostics for invalid skill files. Missing input directories are skipped.
17
- */
18
- export async function loadSkills(env, dirs) {
19
- const skills = [];
20
- const diagnostics = [];
21
- for (const dir of Array.isArray(dirs) ? dirs : [dirs]) {
22
- const rootInfoResult = await env.fileInfo(dir);
23
- if (!rootInfoResult.ok) {
24
- if (rootInfoResult.error.code !== "not_found") {
25
- diagnostics.push({
26
- type: "warning",
27
- code: "file_info_failed",
28
- message: rootInfoResult.error.message,
29
- path: dir,
30
- });
31
- }
32
- continue;
33
- }
34
- const rootInfo = rootInfoResult.value;
35
- if ((await resolveKind(env, rootInfo, diagnostics)) !== "directory")
36
- continue;
37
- const result = await loadSkillsFromDirInternal(env, rootInfo.path, true, ignore(), rootInfo.path);
38
- skills.push(...result.skills);
39
- diagnostics.push(...result.diagnostics);
40
- }
41
- return { skills, diagnostics };
42
- }
43
- /**
44
- * Load skills from source-tagged directories.
45
- *
46
- * Source values are preserved exactly and attached to every loaded skill and diagnostic. The agent package does not
47
- * interpret source values; applications define their own provenance shape.
48
- */
49
- export async function loadSourcedSkills(env, inputs, mapSkill) {
50
- const skills = [];
51
- const diagnostics = [];
52
- for (const input of inputs) {
53
- const result = await loadSkills(env, input.path);
54
- for (const skill of result.skills) {
55
- skills.push({ skill: mapSkill ? mapSkill(skill, input.source) : skill, source: input.source });
56
- }
57
- for (const diagnostic of result.diagnostics)
58
- diagnostics.push({ ...diagnostic, source: input.source });
59
- }
60
- return { skills, diagnostics };
61
- }
62
- async function loadSkillsFromDirInternal(env, dir, includeRootFiles, ignoreMatcher, rootDir) {
63
- const skills = [];
64
- const diagnostics = [];
65
- const dirInfoResult = await env.fileInfo(dir);
66
- if (!dirInfoResult.ok) {
67
- if (dirInfoResult.error.code !== "not_found") {
68
- diagnostics.push({
69
- type: "warning",
70
- code: "file_info_failed",
71
- message: dirInfoResult.error.message,
72
- path: dir,
73
- });
74
- }
75
- return { skills, diagnostics };
76
- }
77
- const dirInfo = dirInfoResult.value;
78
- if ((await resolveKind(env, dirInfo, diagnostics)) !== "directory")
79
- return { skills, diagnostics };
80
- await addIgnoreRules(env, ignoreMatcher, dir, rootDir, diagnostics);
81
- const entriesResult = await env.listDir(dir);
82
- if (!entriesResult.ok) {
83
- diagnostics.push({ type: "warning", code: "list_failed", message: entriesResult.error.message, path: dir });
84
- return { skills, diagnostics };
85
- }
86
- const entries = entriesResult.value;
87
- for (const entry of entries) {
88
- if (entry.name !== "SKILL.md")
89
- continue;
90
- const fullPath = entry.path;
91
- const kind = await resolveKind(env, entry, diagnostics);
92
- if (kind !== "file")
93
- continue;
94
- const relPath = relativeEnvPath(rootDir, fullPath);
95
- if (ignoreMatcher.ignores(relPath))
96
- continue;
97
- const result = await loadSkillFromFile(env, fullPath);
98
- if (result.skill)
99
- skills.push(result.skill);
100
- diagnostics.push(...result.diagnostics);
101
- return { skills, diagnostics };
102
- }
103
- for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
104
- if (entry.name.startsWith(".") || entry.name === "node_modules")
105
- continue;
106
- const fullPath = entry.path;
107
- const kind = await resolveKind(env, entry, diagnostics);
108
- if (!kind)
109
- continue;
110
- const relPath = relativeEnvPath(rootDir, fullPath);
111
- const ignorePath = kind === "directory" ? `${relPath}/` : relPath;
112
- if (ignoreMatcher.ignores(ignorePath))
113
- continue;
114
- if (kind === "directory") {
115
- const result = await loadSkillsFromDirInternal(env, fullPath, false, ignoreMatcher, rootDir);
116
- skills.push(...result.skills);
117
- diagnostics.push(...result.diagnostics);
118
- continue;
119
- }
120
- if (kind !== "file" || !includeRootFiles || !entry.name.endsWith(".md"))
121
- continue;
122
- const result = await loadSkillFromFile(env, fullPath);
123
- if (result.skill)
124
- skills.push(result.skill);
125
- diagnostics.push(...result.diagnostics);
126
- }
127
- return { skills, diagnostics };
128
- }
129
- async function addIgnoreRules(env, ig, dir, rootDir, diagnostics) {
130
- const relativeDir = relativeEnvPath(rootDir, dir);
131
- const prefix = relativeDir ? `${relativeDir}/` : "";
132
- for (const filename of IGNORE_FILE_NAMES) {
133
- const ignorePath = joinEnvPath(dir, filename);
134
- const info = await env.fileInfo(ignorePath);
135
- if (!info.ok) {
136
- if (info.error.code !== "not_found") {
137
- diagnostics.push({
138
- type: "warning",
139
- code: "file_info_failed",
140
- message: info.error.message,
141
- path: ignorePath,
142
- });
143
- }
144
- continue;
145
- }
146
- if (info.value.kind !== "file")
147
- continue;
148
- const content = await env.readTextFile(ignorePath);
149
- if (!content.ok) {
150
- diagnostics.push({ type: "warning", code: "read_failed", message: content.error.message, path: ignorePath });
151
- continue;
152
- }
153
- const patterns = content.value
154
- .split(/\r?\n/)
155
- .map((line) => prefixIgnorePattern(line, prefix))
156
- .filter((line) => Boolean(line));
157
- if (patterns.length > 0)
158
- ig.add(patterns);
159
- }
160
- }
161
- function prefixIgnorePattern(line, prefix) {
162
- const trimmed = line.trim();
163
- if (!trimmed)
164
- return null;
165
- if (trimmed.startsWith("#") && !trimmed.startsWith("\\#"))
166
- return null;
167
- let pattern = line;
168
- let negated = false;
169
- if (pattern.startsWith("!")) {
170
- negated = true;
171
- pattern = pattern.slice(1);
172
- }
173
- else if (pattern.startsWith("\\!")) {
174
- pattern = pattern.slice(1);
175
- }
176
- if (pattern.startsWith("/"))
177
- pattern = pattern.slice(1);
178
- const prefixed = prefix ? `${prefix}${pattern}` : pattern;
179
- return negated ? `!${prefixed}` : prefixed;
180
- }
181
- async function loadSkillFromFile(env, filePath) {
182
- const diagnostics = [];
183
- const rawContent = await env.readTextFile(filePath);
184
- if (!rawContent.ok) {
185
- diagnostics.push({ type: "warning", code: "read_failed", message: rawContent.error.message, path: filePath });
186
- return { skill: null, diagnostics };
187
- }
188
- const parsed = parseFrontmatter(rawContent.value);
189
- if (!parsed.ok) {
190
- diagnostics.push({ type: "warning", code: "parse_failed", message: parsed.error.message, path: filePath });
191
- return { skill: null, diagnostics };
192
- }
193
- const { frontmatter, body } = parsed.value;
194
- const skillDir = dirnameEnvPath(filePath);
195
- const parentDirName = basenameEnvPath(skillDir);
196
- const description = typeof frontmatter.description === "string" ? frontmatter.description : undefined;
197
- for (const error of validateDescription(description)) {
198
- diagnostics.push({ type: "warning", code: "invalid_metadata", message: error, path: filePath });
199
- }
200
- const frontmatterName = typeof frontmatter.name === "string" ? frontmatter.name : undefined;
201
- const name = frontmatterName || parentDirName;
202
- for (const error of validateName(name, parentDirName)) {
203
- diagnostics.push({ type: "warning", code: "invalid_metadata", message: error, path: filePath });
204
- }
205
- if (!description || description.trim() === "") {
206
- return { skill: null, diagnostics };
207
- }
208
- return {
209
- skill: {
210
- name,
211
- description,
212
- content: body,
213
- filePath,
214
- disableModelInvocation: frontmatter["disable-model-invocation"] === true,
215
- },
216
- diagnostics,
217
- };
218
- }
219
- function validateName(name, parentDirName) {
220
- const errors = [];
221
- if (name !== parentDirName)
222
- errors.push(`name "${name}" does not match parent directory "${parentDirName}"`);
223
- if (name.length > MAX_NAME_LENGTH)
224
- errors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);
225
- if (!/^[a-z0-9-]+$/.test(name)) {
226
- errors.push("name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)");
227
- }
228
- if (name.startsWith("-") || name.endsWith("-"))
229
- errors.push("name must not start or end with a hyphen");
230
- if (name.includes("--"))
231
- errors.push("name must not contain consecutive hyphens");
232
- return errors;
233
- }
234
- function validateDescription(description) {
235
- const errors = [];
236
- if (!description || description.trim() === "") {
237
- errors.push("description is required");
238
- }
239
- else if (description.length > MAX_DESCRIPTION_LENGTH) {
240
- errors.push(`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`);
241
- }
242
- return errors;
243
- }
244
- function parseFrontmatter(content) {
245
- try {
246
- const normalized = content.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
247
- if (!normalized.startsWith("---"))
248
- return { ok: true, value: { frontmatter: {}, body: normalized } };
249
- const endIndex = normalized.indexOf("\n---", 3);
250
- if (endIndex === -1)
251
- return { ok: true, value: { frontmatter: {}, body: normalized } };
252
- const yamlString = normalized.slice(4, endIndex);
253
- const body = normalized.slice(endIndex + 4).trim();
254
- return { ok: true, value: { frontmatter: (parse(yamlString) ?? {}), body } };
255
- }
256
- catch (error) {
257
- return { ok: false, error: toError(error) };
258
- }
259
- }
260
- async function resolveKind(env, info, diagnostics) {
261
- if (info.kind === "file" || info.kind === "directory")
262
- return info.kind;
263
- const canonicalPath = await env.canonicalPath(info.path);
264
- if (!canonicalPath.ok) {
265
- if (canonicalPath.error.code !== "not_found") {
266
- diagnostics.push({
267
- type: "warning",
268
- code: "file_info_failed",
269
- message: canonicalPath.error.message,
270
- path: info.path,
271
- });
272
- }
273
- return undefined;
274
- }
275
- const target = await env.fileInfo(canonicalPath.value);
276
- if (!target.ok) {
277
- if (target.error.code !== "not_found") {
278
- diagnostics.push({
279
- type: "warning",
280
- code: "file_info_failed",
281
- message: target.error.message,
282
- path: info.path,
283
- });
284
- }
285
- return undefined;
286
- }
287
- return target.value.kind === "file" || target.value.kind === "directory" ? target.value.kind : undefined;
288
- }
289
- function joinEnvPath(base, child) {
290
- return `${base.replace(/\/+$/, "")}/${child.replace(/^\/+/, "")}`;
291
- }
292
- function dirnameEnvPath(path) {
293
- const normalized = path.replace(/\/+$/, "");
294
- const slashIndex = normalized.lastIndexOf("/");
295
- return slashIndex <= 0 ? "/" : normalized.slice(0, slashIndex);
296
- }
297
- function basenameEnvPath(path) {
298
- const normalized = path.replace(/\/+$/, "");
299
- const slashIndex = normalized.lastIndexOf("/");
300
- return slashIndex === -1 ? normalized : normalized.slice(slashIndex + 1);
301
- }
302
- function relativeEnvPath(root, path) {
303
- const normalizedRoot = root.replace(/\/+$/, "");
304
- const normalizedPath = path.replace(/\/+$/, "");
305
- if (normalizedPath === normalizedRoot)
306
- return "";
307
- return normalizedPath.startsWith(`${normalizedRoot}/`)
308
- ? normalizedPath.slice(normalizedRoot.length + 1)
309
- : normalizedPath.replace(/^\/+/, "");
310
- }
@@ -1,14 +0,0 @@
1
- import { type ExecutionEnv, type ExecutionEnvExecOptions, ExecutionError, type Result } from "../types.js";
2
- export interface ShellCaptureOptions extends Omit<ExecutionEnvExecOptions, "onStdout" | "onStderr"> {
3
- onChunk?: (chunk: string) => void;
4
- }
5
- export interface ShellCaptureResult {
6
- output: string;
7
- exitCode: number | undefined;
8
- cancelled: boolean;
9
- truncated: boolean;
10
- fullOutputPath?: string;
11
- }
12
- export declare function sanitizeBinaryOutput(str: string): string;
13
- export declare function executeShellWithCapture(env: ExecutionEnv, command: string, options?: ShellCaptureOptions): Promise<Result<ShellCaptureResult, ExecutionError>>;
14
- //# sourceMappingURL=shell-output.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shell-output.d.ts","sourceRoot":"","sources":["../../../../../src/sdk/agent-core/harness/utils/shell-output.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,cAAc,EAGd,KAAK,MAAM,EAEX,MAAM,aAAa,CAAC;AAGrB,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,uBAAuB,EAAE,UAAU,GAAG,UAAU,CAAC;IAClG,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,kBAAkB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAQD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAWxD;AAED,wBAAsB,uBAAuB,CAC5C,GAAG,EAAE,YAAY,EACjB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,mBAAmB,GAC3B,OAAO,CAAC,MAAM,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC,CAgGrD"}