@codeworksh/plugin 0.0.1-dev.20260922103030

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 (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +111 -0
  3. package/error-ClDISWlT.d.mts +11 -0
  4. package/event-rIZpnOTo.d.mts +895 -0
  5. package/event.d.mts +2 -0
  6. package/event.mjs +125 -0
  7. package/event.mjs.map +1 -0
  8. package/filesystem-Cp-KapCE.d.mts +142 -0
  9. package/ids-CHjmAdTc.d.mts +43 -0
  10. package/ids.d.mts +2 -0
  11. package/ids.mjs +48 -0
  12. package/ids.mjs.map +1 -0
  13. package/index.d.mts +3 -0
  14. package/index.mjs +3 -0
  15. package/io-BYs7hbiY.d.mts +497 -0
  16. package/location-D4hAfuXF.d.mts +61 -0
  17. package/location.d.mts +2 -0
  18. package/location.mjs +48 -0
  19. package/location.mjs.map +1 -0
  20. package/package.json +200 -0
  21. package/plugin/prompt.d.mts +2 -0
  22. package/plugin/prompt.mjs +7 -0
  23. package/plugin/prompt.mjs.map +1 -0
  24. package/plugin/tool.d.mts +2 -0
  25. package/plugin/tool.mjs +29 -0
  26. package/plugin/tool.mjs.map +1 -0
  27. package/plugin-DbJEpY3M.d.mts +140 -0
  28. package/plugin-lorpq7Oi.mjs +41 -0
  29. package/plugin-lorpq7Oi.mjs.map +1 -0
  30. package/plugin.d.mts +4 -0
  31. package/plugin.mjs +4 -0
  32. package/posix.d.mts +6 -0
  33. package/posix.mjs +8 -0
  34. package/posix.mjs.map +1 -0
  35. package/project-CLGsIFD-.d.mts +21 -0
  36. package/project.d.mts +2 -0
  37. package/project.mjs +22 -0
  38. package/project.mjs.map +1 -0
  39. package/prompt-BcpagjGh.d.mts +10 -0
  40. package/repo.d.mts +42 -0
  41. package/repo.mjs +46 -0
  42. package/repo.mjs.map +1 -0
  43. package/rolldown-runtime-D7D4PA-g.mjs +13 -0
  44. package/sandbox/driver.d.mts +2 -0
  45. package/sandbox/driver.mjs +63 -0
  46. package/sandbox/driver.mjs.map +1 -0
  47. package/sandbox/error.d.mts +7 -0
  48. package/sandbox/error.mjs +15 -0
  49. package/sandbox/error.mjs.map +1 -0
  50. package/sandbox/errors.d.mts +2 -0
  51. package/sandbox/errors.mjs +160 -0
  52. package/sandbox/errors.mjs.map +1 -0
  53. package/sandbox/filesystem.d.mts +2 -0
  54. package/sandbox/filesystem.mjs +142 -0
  55. package/sandbox/filesystem.mjs.map +1 -0
  56. package/sandbox/instance.d.mts +2 -0
  57. package/sandbox/instance.mjs +144 -0
  58. package/sandbox/instance.mjs.map +1 -0
  59. package/sandbox/io.d.mts +2 -0
  60. package/sandbox/io.mjs +127 -0
  61. package/sandbox/io.mjs.map +1 -0
  62. package/sandbox/resource.d.mts +28 -0
  63. package/sandbox/resource.mjs +29 -0
  64. package/sandbox/resource.mjs.map +1 -0
  65. package/sandbox/shell.d.mts +2 -0
  66. package/sandbox/shell.mjs +93 -0
  67. package/sandbox/shell.mjs.map +1 -0
  68. package/sandbox.d.mts +17 -0
  69. package/sandbox.mjs +39 -0
  70. package/sandbox.mjs.map +1 -0
  71. package/schema.d.mts +91 -0
  72. package/schema.mjs +105 -0
  73. package/schema.mjs.map +1 -0
  74. package/settings-CYL6yyDD.d.mts +193 -0
  75. package/settings.d.mts +2 -0
  76. package/settings.mjs +102 -0
  77. package/settings.mjs.map +1 -0
  78. package/shell-CZ6Y4lNU.d.mts +109 -0
  79. package/space-CR-9UxdT.d.mts +25 -0
  80. package/space.d.mts +2 -0
  81. package/space.mjs +33 -0
  82. package/space.mjs.map +1 -0
  83. package/tool/error.d.mts +2 -0
  84. package/tool/error.mjs +11 -0
  85. package/tool/error.mjs.map +1 -0
  86. package/tool/progress.d.mts +2 -0
  87. package/tool/progress.mjs +11 -0
  88. package/tool/progress.mjs.map +1 -0
  89. package/tool-BoVqkYvL.d.mts +287 -0
  90. package/tool-DuYBgiJf.d.mts +142 -0
  91. package/tool.d.mts +2 -0
  92. package/tool.mjs +71 -0
  93. package/tool.mjs.map +1 -0
package/event.d.mts ADDED
@@ -0,0 +1,2 @@
1
+ import { a as ID, c as define, d as inventory, f as latest, i as Definition, l as durable, n as AikitToolCallTerminalPart, o as Payload, p as versionedType, r as Data, s as PublishOptions, t as AikitAssistantMessage, u as event_d_exports } from "./event-rIZpnOTo.mjs";
2
+ export { AikitAssistantMessage, AikitToolCallTerminalPart, Data, Definition, event_d_exports as EventSchema, ID, Payload, PublishOptions, define, durable, inventory, latest, versionedType };
package/event.mjs ADDED
@@ -0,0 +1,125 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
+ import { isAikitAssistantMessage, isAikitToolCallTerminalPart, optional, validateAikitAssistantMessage, validateAikitToolCallTerminalPart, withStatics } from "./schema.mjs";
3
+ import "@codeworksh/aikit";
4
+ import { Effect, Schema, SchemaGetter, SchemaIssue } from "effect";
5
+ import { uuidv7 } from "uuidv7";
6
+ //#region src/event.ts
7
+ var event_exports = /* @__PURE__ */ __exportAll({
8
+ AikitAssistantMessage: () => AikitAssistantMessage,
9
+ AikitToolCallTerminalPart: () => AikitToolCallTerminalPart,
10
+ EventSchema: () => event_exports,
11
+ ID: () => ID,
12
+ define: () => define,
13
+ durable: () => durable,
14
+ inventory: () => inventory,
15
+ latest: () => latest,
16
+ versionedType: () => versionedType
17
+ });
18
+ /** Undeclared fields used only while aikit is assembling a streamed part. */
19
+ const aikitTransientFields = {
20
+ text: ["streamId"],
21
+ image: [],
22
+ thinking: ["streamId"],
23
+ toolCall: ["partialJson"]
24
+ };
25
+ const omit = (value, keys) => {
26
+ if (!keys.some((key) => key in value)) return value;
27
+ const copy = { ...value };
28
+ for (const key of keys) delete copy[key];
29
+ return copy;
30
+ };
31
+ const canonicalizeAikitAssistantMessage = (message) => ({
32
+ ...message,
33
+ parts: message.parts.map((part) => omit(part, aikitTransientFields[part.type]))
34
+ });
35
+ const reasonOf = (cause) => cause instanceof Error ? cause.message : String(cause);
36
+ const decodeAikitAssistantMessage = (value, options) => Effect.try({
37
+ try: () => canonicalizeAikitAssistantMessage(validateAikitAssistantMessage(value, "aikit assistant message")),
38
+ catch: (cause) => new SchemaIssue.InvalidValue({ message: reasonOf(cause) }, value, options)
39
+ });
40
+ const aikitAssistantMessageDeclared = Schema.declare(isAikitAssistantMessage, { expected: "aikit AssistantMessage" });
41
+ /**
42
+ * Effect Schema adapter for aikit's TypeBox assistant message. Durable LLM
43
+ * events use it to validate their payload and strip streaming-only fields.
44
+ */
45
+ const AikitAssistantMessage = Schema.Unknown.pipe(Schema.decodeTo(aikitAssistantMessageDeclared, {
46
+ decode: SchemaGetter.transformEffect(decodeAikitAssistantMessage),
47
+ encode: SchemaGetter.transformEffect(decodeAikitAssistantMessage)
48
+ }));
49
+ const decodeAikitToolCallTerminalPart = (value, options) => Effect.try({
50
+ try: () => validateAikitToolCallTerminalPart(value, "aikit terminal toolcall part"),
51
+ catch: (cause) => new SchemaIssue.InvalidValue({ message: reasonOf(cause) }, value, options)
52
+ });
53
+ const aikitToolCallTerminalPartDeclared = Schema.declare(isAikitToolCallTerminalPart, { expected: "aikit terminal toolcall part" });
54
+ const AikitToolCallTerminalPart = Schema.Unknown.pipe(Schema.decodeTo(aikitToolCallTerminalPartDeclared, {
55
+ decode: SchemaGetter.transformEffect(decodeAikitToolCallTerminalPart),
56
+ encode: SchemaGetter.transformEffect(decodeAikitToolCallTerminalPart)
57
+ }));
58
+ const ID = Schema.String.pipe(Schema.brand("Event.ID"), withStatics((schema) => ({ create: () => schema.make(`evt_${uuidv7()}`) })));
59
+ function define(input) {
60
+ const data = Schema.Struct(input.schema);
61
+ return Schema.Struct({
62
+ id: ID,
63
+ metadata: optional(Schema.Record(Schema.String, Schema.String)),
64
+ type: Schema.Literal(input.type),
65
+ durable: optional(Schema.Struct({
66
+ aggregateId: Schema.String,
67
+ seq: Schema.Int,
68
+ version: Schema.Int
69
+ })),
70
+ data
71
+ }).annotate({ identifier: input.type }).pipe(withStatics(() => ({
72
+ type: input.type,
73
+ ...input.durable === void 0 ? {} : { durable: input.durable },
74
+ data
75
+ })));
76
+ }
77
+ function inventory(...definitions) {
78
+ return Object.freeze(definitions);
79
+ }
80
+ function versionedType(type, version) {
81
+ return `${type}.${version}`;
82
+ }
83
+ function durable(definitions) {
84
+ return readonlyMap(definitions.reduce((result, definition) => {
85
+ if (!definition.durable) return result;
86
+ const key = versionedType(definition.type, definition.durable.version);
87
+ if (result.has(key)) throw new Error(`duplicate durable event definition for ${key}`);
88
+ result.set(key, definition);
89
+ return result;
90
+ }, /* @__PURE__ */ new Map()));
91
+ }
92
+ function readonlyMap(map) {
93
+ const result = Object.freeze({
94
+ get size() {
95
+ return map.size;
96
+ },
97
+ entries: () => map.entries(),
98
+ forEach: (callback, thisArg) => map.forEach((value, key) => callback.call(thisArg, value, key, result)),
99
+ get: (key) => map.get(key),
100
+ has: (key) => map.has(key),
101
+ keys: () => map.keys(),
102
+ values: () => map.values(),
103
+ [Symbol.iterator]: () => map[Symbol.iterator]()
104
+ });
105
+ return result;
106
+ }
107
+ function latest(definitions) {
108
+ return readonlyMap(definitions.reduce((result, definition) => {
109
+ const existing = result.get(definition.type);
110
+ if (!existing) {
111
+ result.set(definition.type, definition);
112
+ return result;
113
+ }
114
+ if (definition.durable && existing.durable && definition.durable.version !== existing.durable.version) {
115
+ if (definition.durable.version > existing.durable.version) result.set(definition.type, definition);
116
+ return result;
117
+ }
118
+ if (definition !== existing) throw new Error(`duplicate latest event definition for ${definition.type}`);
119
+ return result;
120
+ }, /* @__PURE__ */ new Map()));
121
+ }
122
+ //#endregion
123
+ export { AikitAssistantMessage, AikitToolCallTerminalPart, event_exports as EventSchema, ID, define, durable, inventory, latest, versionedType };
124
+
125
+ //# sourceMappingURL=event.mjs.map
package/event.mjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.mjs","names":[],"sources":["../../src/event.ts"],"sourcesContent":["import { Message } from \"@codeworksh/aikit\";\nimport { Effect, Schema, type SchemaAST, SchemaGetter, SchemaIssue } from \"effect\";\nimport { uuidv7 } from \"uuidv7\";\nimport {\n\tisAikitAssistantMessage,\n\tisAikitToolCallTerminalPart,\n\toptional,\n\tvalidateAikitAssistantMessage,\n\tvalidateAikitToolCallTerminalPart,\n\twithStatics,\n} from \"./schema.ts\";\n\ntype AikitAssistantPart = Message.AssistantMessage[\"parts\"][number];\n\n/** Undeclared fields used only while aikit is assembling a streamed part. */\nconst aikitTransientFields: Readonly<Record<AikitAssistantPart[\"type\"], ReadonlyArray<string>>> = {\n\ttext: [\"streamId\"],\n\timage: [],\n\tthinking: [\"streamId\"],\n\ttoolCall: [\"partialJson\"],\n};\n\nconst omit = <T extends object>(value: T, keys: ReadonlyArray<string>): T => {\n\tif (!keys.some((key) => key in value)) return value;\n\tconst copy = { ...value } as T & Record<string, unknown>;\n\tfor (const key of keys) delete copy[key];\n\treturn copy;\n};\n\nconst canonicalizeAikitAssistantMessage = (message: Message.AssistantMessage): Message.AssistantMessage => ({\n\t...message,\n\tparts: message.parts.map((part) => omit(part, aikitTransientFields[part.type])),\n});\n\nconst reasonOf = (cause: unknown): string => (cause instanceof Error ? cause.message : String(cause));\n\nconst decodeAikitAssistantMessage = (value: unknown, options: SchemaAST.ParseOptions) =>\n\tEffect.try({\n\t\ttry: () => canonicalizeAikitAssistantMessage(validateAikitAssistantMessage(value, \"aikit assistant message\")),\n\t\tcatch: (cause) => new SchemaIssue.InvalidValue({ message: reasonOf(cause) }, value, options),\n\t});\n\nconst aikitAssistantMessageDeclared = Schema.declare<Message.AssistantMessage>(isAikitAssistantMessage, {\n\texpected: \"aikit AssistantMessage\",\n});\n\n/**\n * Effect Schema adapter for aikit's TypeBox assistant message. Durable LLM\n * events use it to validate their payload and strip streaming-only fields.\n */\nexport const AikitAssistantMessage = Schema.Unknown.pipe(\n\tSchema.decodeTo(aikitAssistantMessageDeclared, {\n\t\tdecode: SchemaGetter.transformEffect(decodeAikitAssistantMessage),\n\t\tencode: SchemaGetter.transformEffect(decodeAikitAssistantMessage),\n\t}),\n);\nexport type AikitAssistantMessage = typeof AikitAssistantMessage.Type;\n\nconst decodeAikitToolCallTerminalPart = (value: unknown, options: SchemaAST.ParseOptions) =>\n\tEffect.try({\n\t\ttry: () => validateAikitToolCallTerminalPart(value, \"aikit terminal toolcall part\"),\n\t\tcatch: (cause) => new SchemaIssue.InvalidValue({ message: reasonOf(cause) }, value, options),\n\t});\n\nconst aikitToolCallTerminalPartDeclared = Schema.declare<Message.ToolCallTerminalPart>(isAikitToolCallTerminalPart, {\n\texpected: \"aikit terminal toolcall part\",\n});\n\nexport const AikitToolCallTerminalPart = Schema.Unknown.pipe(\n\tSchema.decodeTo(aikitToolCallTerminalPartDeclared, {\n\t\tdecode: SchemaGetter.transformEffect(decodeAikitToolCallTerminalPart),\n\t\tencode: SchemaGetter.transformEffect(decodeAikitToolCallTerminalPart),\n\t}),\n);\nexport type AikitToolCallTerminalPart = typeof AikitToolCallTerminalPart.Type;\n\nexport const ID = Schema.String.pipe(\n\tSchema.brand(\"Event.ID\"),\n\twithStatics((schema) => ({\n\t\tcreate: () => schema.make(`evt_${uuidv7()}`),\n\t})),\n);\nexport type ID = typeof ID.Type;\n\nexport type Definition<\n\tType extends string = string,\n\tDataSchema extends Schema.Codec<unknown, unknown> = Schema.Codec<unknown, unknown>,\n> = Schema.Top & {\n\treadonly type: Type;\n\treadonly durable?: {\n\t\treadonly version: number; // event versioning for decoding in later time\n\t\treadonly aggregate: string;\n\t};\n\treadonly data: DataSchema;\n};\n\nexport type Data<D extends Definition> = Schema.Schema.Type<D[\"data\"]>;\n\n/** Publish-time options. Lives beside the definition so the plugin-facing publisher can name it. */\nexport interface PublishOptions {\n\t/** Caller-supplied event ID. Publishing the same ID twice is a defect, not an upsert. */\n\treadonly id?: ID;\n\t/**\n\t * Publish-time context — correlation, tracing — carried to projectors on the\n\t * in-memory payload and deliberately not stored in the event row. A projector\n\t * persists it into its own projection if it means something there; the log\n\t * records what happened, not who asked. It therefore does not survive a\n\t * durable reread or a rebuild, which `event.test.ts` pins explicitly.\n\t */\n\treadonly metadata?: Record<string, string>;\n}\n\nexport type Payload<D extends Definition = Definition> = {\n\treadonly id: ID;\n\treadonly type: D[\"type\"];\n\treadonly data: Data<D>;\n\treadonly durable?: {\n\t\treadonly aggregateId: string;\n\t\treadonly seq: number;\n\t\treadonly version: number;\n\t};\n\treadonly metadata?: Record<string, string>;\n};\n\nexport function define<\n\tconst Type extends string,\n\tconst Fields extends Readonly<Record<PropertyKey, Schema.Codec<unknown, unknown>>>,\n>(input: {\n\treadonly type: Type;\n\treadonly durable?: {\n\t\treadonly version: number;\n\t\treadonly aggregate: string;\n\t};\n\treadonly schema: Fields;\n}) {\n\tconst data = Schema.Struct(input.schema);\n\treturn Schema.Struct({\n\t\tid: ID,\n\t\tmetadata: optional(Schema.Record(Schema.String, Schema.String)),\n\t\ttype: Schema.Literal(input.type),\n\t\tdurable: optional(Schema.Struct({ aggregateId: Schema.String, seq: Schema.Int, version: Schema.Int })),\n\t\tdata,\n\t})\n\t\t.annotate({ identifier: input.type })\n\t\t.pipe(\n\t\t\twithStatics(() => ({\n\t\t\t\ttype: input.type,\n\t\t\t\t...(input.durable === undefined ? {} : { durable: input.durable }),\n\t\t\t\tdata,\n\t\t\t})),\n\t\t) satisfies Definition<Type, typeof data>;\n}\n\n// Register all the event definitions.\nexport function inventory<const Definitions extends ReadonlyArray<Definition>>(...definitions: Definitions) {\n\treturn Object.freeze(definitions);\n}\n\nexport function versionedType(type: string, version: number) {\n\treturn `${type}.${version}`;\n}\n\nexport function durable<const Definitions extends ReadonlyArray<Definition>>(definitions: Definitions) {\n\treturn readonlyMap(\n\t\tdefinitions.reduce((result, definition) => {\n\t\t\tif (!definition.durable) return result;\n\t\t\tconst key = versionedType(definition.type, definition.durable.version);\n\t\t\tif (result.has(key)) throw new Error(`duplicate durable event definition for ${key}`);\n\t\t\tresult.set(key, definition);\n\t\t\treturn result;\n\t\t}, new Map<string, Definitions[number]>()),\n\t);\n}\n\nfunction readonlyMap<Key, Value>(map: Map<Key, Value>): ReadonlyMap<Key, Value> {\n\tconst result: ReadonlyMap<Key, Value> = Object.freeze({\n\t\tget size() {\n\t\t\treturn map.size;\n\t\t},\n\t\tentries: () => map.entries(),\n\t\tforEach: (callback: (value: Value, key: Key, map: ReadonlyMap<Key, Value>) => void, thisArg?: unknown) =>\n\t\t\tmap.forEach((value, key) => callback.call(thisArg, value, key, result)),\n\t\tget: (key: Key) => map.get(key),\n\t\thas: (key: Key) => map.has(key),\n\t\tkeys: () => map.keys(),\n\t\tvalues: () => map.values(),\n\t\t[Symbol.iterator]: () => map[Symbol.iterator](),\n\t});\n\treturn result;\n}\n\nexport function latest(definitions: ReadonlyArray<Definition>) {\n\treturn readonlyMap(\n\t\tdefinitions.reduce((result, definition) => {\n\t\t\tconst existing = result.get(definition.type);\n\t\t\tif (!existing) {\n\t\t\t\tresult.set(definition.type, definition);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tif (definition.durable && existing.durable && definition.durable.version !== existing.durable.version) {\n\t\t\t\tif (definition.durable.version > existing.durable.version) result.set(definition.type, definition);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tif (definition !== existing) throw new Error(`duplicate latest event definition for ${definition.type}`);\n\t\t\treturn result;\n\t\t}, new Map<string, Definition>()),\n\t);\n}\n\nexport * as EventSchema from \"./event.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAeA,MAAM,uBAA4F;CACjG,MAAM,CAAC,UAAU;CACjB,OAAO,CAAC;CACR,UAAU,CAAC,UAAU;CACrB,UAAU,CAAC,aAAa;AACzB;AAEA,MAAM,QAA0B,OAAU,SAAmC;CAC5E,IAAI,CAAC,KAAK,MAAM,QAAQ,OAAO,KAAK,GAAG,OAAO;CAC9C,MAAM,OAAO,EAAE,GAAG,MAAM;CACxB,KAAK,MAAM,OAAO,MAAM,OAAO,KAAK;CACpC,OAAO;AACR;AAEA,MAAM,qCAAqC,aAAiE;CAC3G,G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C;CACD,OAAO;AACR;AAEA,SAAgB,OAAO,aAAwC;CAC9D,OAAO,YACN,YAAY,QAAQ,QAAQ,eAAe;EAC1C,MAAM,WAAW,OAAO,IAAI,WAAW,IAAI;EAC3C,IAAI,CAAC,UAAU;GACd,OAAO,IAAI,WAAW,MAAM,UAAU;GACtC,OAAO;EACR;EACA,IAAI,WAAW,WAAW,SAAS,WAAW,WAAW,QAAQ,YAAY,SAAS,QAAQ,SAAS;GACtG,IAAI,WAAW,QAAQ,UAAU,SAAS,QAAQ,SAAS,OAAO,IAAI,WAAW,MAAM,UAAU;GACjG,OAAO;EACR;EACA,IAAI,eAAe,UAAU,MAAM,IAAI,MAAM,yCAAyC,WAAW,MAAM;EACvG,OAAO;CACR,mBAAG,IAAI,IAAwB,CAAC,CACjC;AACD"}
@@ -0,0 +1,142 @@
1
+ import { Context, Effect, Schema } from "effect";
2
+ declare namespace filesystem_d_exports {
3
+ export { FileStat, FileSystemError, Interface, OperationUnsupportedError, Provider, RmOptions, filesystem_d_exports as SandboxFileSystem, Service, fromProvider, isNotFoundError, realpathScripts, validateRmOptions, withCwd };
4
+ }
5
+ declare const OperationUnsupportedError_base: Schema.Class<OperationUnsupportedError, Schema.TaggedStruct<"OperationUnsupportedError", {
6
+ readonly operation: Schema.String;
7
+ readonly message: Schema.String;
8
+ }>, import("effect/Cause").YieldableError>;
9
+ /**
10
+ * The runtime filesystem contract, independent of any backend.
11
+ *
12
+ * Two surfaces, deliberately:
13
+ * - {@link Provider} is what a backend implements — plain promises that reject,
14
+ * matching every SDK we wrap.
15
+ * - {@link Interface} is what the harness consumes — Effect with a typed error
16
+ * channel and tracing spans. {@link fromProvider} bridges the two exactly
17
+ * once, so no consumer ever writes `Effect.tryPromise` against a filesystem.
18
+ *
19
+ * Implementations:
20
+ * - Local:
21
+ * implement it over a VFS (`./local`);
22
+ * local filesystem use OS primitives; hence have broader filesytem capabilities.
23
+ *
24
+ * - Remote:
25
+ * implement it over a provider (`./remote`).
26
+ * remote filesytems depends on the interface provided by the remote provider; hence can have limited filesytem capabilities.
27
+ *
28
+ * `isFile`/`isDirectory` are required booleans; size, mtime, and isSymbolicLink are omitted when the
29
+ * backend cannot report them — never fabricated.
30
+ *
31
+ * **Paths are POSIX, and the harness is Unix-only (for now!).** Every path uses `/`
32
+ * separators on both the host and inside a sandbox — Windows is not supported,
33
+ * so no translation layer exists. Consumers must use the shared Effect POSIX
34
+ * path implementation, never the platform default, or a host running the harness would
35
+ * impose its own flavour on a remote sandbox's paths. Relative paths resolve
36
+ * against the backend's configured `cwd`.
37
+ */
38
+ declare class OperationUnsupportedError extends OperationUnsupportedError_base {}
39
+ declare const FileSystemError_base: Schema.Class<FileSystemError, Schema.TaggedStruct<"SandboxFileSystemError", {
40
+ readonly method: Schema.String;
41
+ readonly path: Schema.String;
42
+ readonly cause: Schema.optional<Schema.Defect>;
43
+ }>, import("effect/Cause").YieldableError>;
44
+ /** A backend operation failed. `cause` carries the provider's own rejection. */
45
+ declare class FileSystemError extends FileSystemError_base {}
46
+ interface FileStat {
47
+ readonly isFile: boolean;
48
+ readonly isDirectory: boolean;
49
+ readonly isSymbolicLink?: boolean;
50
+ readonly size?: number;
51
+ readonly mtime?: Date;
52
+ }
53
+ interface RmOptions {
54
+ readonly recursive?: boolean;
55
+ readonly force?: boolean;
56
+ }
57
+ /** Whether a provider failure means the path itself is definitively absent. */
58
+ declare const isNotFoundError: (cause: unknown) => boolean;
59
+ /**
60
+ * Shell forms of `realpath` for backends that only expose a process API.
61
+ * `pwd -P` is the portable primitive: directories resolve directly, anything
62
+ * else resolves its parent and keeps the final name as given. Run as
63
+ * `sh -c <script> _ <path>`; try the first, fall back to the second.
64
+ */
65
+ declare const realpathScripts: readonly ['cd -- "$1" && pwd -P', 'cd -- "$(dirname -- "$1")" && printf \'%s/%s\' "$(pwd -P)" "$(basename -- "$1")"'];
66
+ /**
67
+ * The backend-facing contract. Backends author plain promises and let them
68
+ * reject; {@link fromProvider} turns rejections into typed failures.
69
+ */
70
+ interface Provider {
71
+ readonly readFile: (path: string) => Promise<string>;
72
+ readonly readFileBuffer: (path: string) => Promise<Uint8Array>;
73
+ /**
74
+ * Write the file. Parents may be missing — do not create them here;
75
+ * {@link fromProvider} owns that guarantee for every backend.
76
+ */
77
+ readonly writeFile: (path: string, content: string | Uint8Array) => Promise<void>;
78
+ readonly stat: (path: string) => Promise<FileStat>;
79
+ readonly readdir: (path: string) => Promise<string[]>;
80
+ readonly exists: (path: string) => Promise<boolean>;
81
+ readonly mkdir: (path: string, options?: {
82
+ recursive?: boolean;
83
+ }) => Promise<void>;
84
+ readonly rm: (path: string, options?: RmOptions) => Promise<void>;
85
+ /** Canonical absolute path with symlinks resolved; rejects when the path does not exist. */
86
+ readonly realpath: (path: string) => Promise<string>;
87
+ /**
88
+ * Metadata for the directory entry itself rather than a symlink's target.
89
+ * Optional: a backend whose `stat` has mixed symlink semantics implements it
90
+ * so symlink identity is asked for explicitly, never inferred.
91
+ */
92
+ readonly lstat?: (path: string) => Promise<FileStat>;
93
+ }
94
+ /**
95
+ * The consumer-facing contract. `exists` distinguishes "absent" from "could not
96
+ * tell": a backend failure is a typed failure, not `false`, so a caller acting
97
+ * on absence never acts on a network blip. Use `SandboxFs.existsOrFalse` where
98
+ * a best-effort answer really is wanted.
99
+ */
100
+ interface Interface {
101
+ readonly readFile: (path: string) => Effect.Effect<string, FileSystemError>;
102
+ readonly readFileBuffer: (path: string) => Effect.Effect<Uint8Array, FileSystemError>;
103
+ /** Creates missing parent directories, on every backend. */
104
+ readonly writeFile: (path: string, content: string | Uint8Array) => Effect.Effect<void, FileSystemError>;
105
+ readonly stat: (path: string) => Effect.Effect<FileStat, FileSystemError>;
106
+ readonly readdir: (path: string) => Effect.Effect<string[], FileSystemError>;
107
+ readonly exists: (path: string) => Effect.Effect<boolean, FileSystemError>;
108
+ readonly mkdir: (path: string, options?: {
109
+ recursive?: boolean;
110
+ }) => Effect.Effect<void, FileSystemError>;
111
+ readonly rm: (path: string, options?: RmOptions) => Effect.Effect<void, FileSystemError | OperationUnsupportedError>;
112
+ /** Canonical absolute path with symlinks resolved; fails when the path does not exist. */
113
+ readonly realpath: (path: string) => Effect.Effect<string, FileSystemError>;
114
+ readonly lstat?: (path: string) => Effect.Effect<FileStat, FileSystemError>;
115
+ }
116
+ declare const Service_base: Context.ServiceClass<Service, "@codeworksh/plugin/sandbox/filesystem/Service", Interface>;
117
+ /** The runtime filesystem service — the live {@link Interface} for the active sandbox. */
118
+ declare class Service extends Service_base {}
119
+ /**
120
+ * Reject `rm` options a provider does not implement, before any mutation. Only
121
+ * `recursive` and `force` are part of the contract; anything else is refused
122
+ * loudly rather than silently ignored.
123
+ */
124
+ declare const validateRmOptions: (options: RmOptions | undefined, operation?: string) => Effect.Effect<void, OperationUnsupportedError>;
125
+ /**
126
+ * Lift a {@link Provider} into the runtime {@link Interface}: one place that
127
+ * converts rejections into {@link FileSystemError}, validates `rm` options,
128
+ * creates missing parents on write, and names a tracing span per operation.
129
+ */
130
+ declare const fromProvider: (provider: Provider) => Interface;
131
+ /**
132
+ * Bind a cwd-neutral filesystem to one mount's working directory.
133
+ *
134
+ * The counterpart of `Shell.withCwd`, and the reason relative paths mean the
135
+ * same thing to both: a shared transport stays rooted at the namespace root, so
136
+ * resolution happens here, per mount, rather than inside a VFS whose `chdir` is
137
+ * global state two mounts would fight over.
138
+ */
139
+ declare const withCwd: (fs: Interface, cwd: string) => Interface;
140
+ //#endregion
141
+ export { Provider as a, filesystem_d_exports as c, realpathScripts as d, validateRmOptions as f, OperationUnsupportedError as i, fromProvider as l, FileSystemError as n, RmOptions as o, withCwd as p, Interface as r, Service as s, FileStat as t, isNotFoundError as u };
142
+ //# sourceMappingURL=filesystem-Cp-KapCE.d.mts.map
@@ -0,0 +1,43 @@
1
+ import { Schema } from "effect";
2
+ //#region src/ids.d.ts
3
+ /**
4
+ * The identifiers that cross the plugin boundary.
5
+ *
6
+ * A plugin reads a session id off its context and a message id off every tool call, so both
7
+ * brands have to be the ones the harness itself mints -- a structurally identical brand declared
8
+ * twice is two types, and a plugin would have to cast to hand either back. They live here, in the
9
+ * package both sides depend on, rather than being re-declared on each side.
10
+ */
11
+ declare const SessionID: Schema.brand<Schema.String, "Session.ID"> & {
12
+ ascending: (id?: string) => string & import("effect/Brand").Brand<"Session.ID">;
13
+ create: () => string & import("effect/Brand").Brand<"Session.ID">;
14
+ };
15
+ type SessionID = typeof SessionID.Type;
16
+ /**
17
+ * A conversation message id.
18
+ *
19
+ * Deliberately unprefixed. aikit mints assistant message ids itself, as bare
20
+ * uuidv7, and `stream()` accepts no id -- so any naming rule of ours would have
21
+ * to be imposed on messages aikit hands us, by rewriting a field of the value we
22
+ * were given. Sharing aikit's format instead means an id means the same thing on
23
+ * both sides of the boundary and never needs translating.
24
+ *
25
+ * The brand carries the meaning; uuidv7 keeps ids time-ordered, so they sort by
26
+ * creation.
27
+ */
28
+ declare const MessageID: Schema.brand<Schema.String, "Message.ID"> & {
29
+ create: () => string & import("effect/Brand").Brand<"Message.ID">;
30
+ /**
31
+ * Adopt an id minted elsewhere -- in practice aikit's, which arrives as a
32
+ * plain string on every stream event and inside every assistant message.
33
+ *
34
+ * `make` does the same thing. This exists so the boundary where a foreign
35
+ * id enters the domain is named and greppable, and so the pairing with
36
+ * `create` says which side chose the id.
37
+ */
38
+ from: (id: string) => string & import("effect/Brand").Brand<"Message.ID">;
39
+ };
40
+ type MessageID = typeof MessageID.Type;
41
+ //#endregion
42
+ export { SessionID as n, MessageID as t };
43
+ //# sourceMappingURL=ids-CHjmAdTc.d.mts.map
package/ids.d.mts ADDED
@@ -0,0 +1,2 @@
1
+ import { n as SessionID, t as MessageID } from "./ids-CHjmAdTc.mjs";
2
+ export { MessageID, SessionID };
package/ids.mjs ADDED
@@ -0,0 +1,48 @@
1
+ import { withStatics } from "./schema.mjs";
2
+ import { Schema } from "effect";
3
+ import { uuidv7 } from "uuidv7";
4
+ //#region src/ids.ts
5
+ /**
6
+ * The identifiers that cross the plugin boundary.
7
+ *
8
+ * A plugin reads a session id off its context and a message id off every tool call, so both
9
+ * brands have to be the ones the harness itself mints -- a structurally identical brand declared
10
+ * twice is two types, and a plugin would have to cast to hand either back. They live here, in the
11
+ * package both sides depend on, rather than being re-declared on each side.
12
+ */
13
+ const SessionID = Schema.String.check(Schema.isStartsWith("ses")).pipe(Schema.brand("Session.ID"), withStatics((schema) => ({
14
+ ascending: (id) => {
15
+ if (!id) return schema.make("ses_" + uuidv7());
16
+ if (!id.startsWith("ses")) throw new Error(`ID ${id} does not start with ses`);
17
+ return schema.make(id);
18
+ },
19
+ create: () => schema.make("ses_" + uuidv7())
20
+ })));
21
+ /**
22
+ * A conversation message id.
23
+ *
24
+ * Deliberately unprefixed. aikit mints assistant message ids itself, as bare
25
+ * uuidv7, and `stream()` accepts no id -- so any naming rule of ours would have
26
+ * to be imposed on messages aikit hands us, by rewriting a field of the value we
27
+ * were given. Sharing aikit's format instead means an id means the same thing on
28
+ * both sides of the boundary and never needs translating.
29
+ *
30
+ * The brand carries the meaning; uuidv7 keeps ids time-ordered, so they sort by
31
+ * creation.
32
+ */
33
+ const MessageID = Schema.String.pipe(Schema.brand("Message.ID"), withStatics((schema) => ({
34
+ create: () => schema.make(uuidv7()),
35
+ /**
36
+ * Adopt an id minted elsewhere -- in practice aikit's, which arrives as a
37
+ * plain string on every stream event and inside every assistant message.
38
+ *
39
+ * `make` does the same thing. This exists so the boundary where a foreign
40
+ * id enters the domain is named and greppable, and so the pairing with
41
+ * `create` says which side chose the id.
42
+ */
43
+ from: (id) => schema.make(id)
44
+ })));
45
+ //#endregion
46
+ export { MessageID, SessionID };
47
+
48
+ //# sourceMappingURL=ids.mjs.map
package/ids.mjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.mjs","names":[],"sources":["../../src/ids.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport { uuidv7 } from \"uuidv7\";\nimport { withStatics } from \"./schema.ts\";\n\n/**\n * The identifiers that cross the plugin boundary.\n *\n * A plugin reads a session id off its context and a message id off every tool call, so both\n * brands have to be the ones the harness itself mints -- a structurally identical brand declared\n * twice is two types, and a plugin would have to cast to hand either back. They live here, in the\n * package both sides depend on, rather than being re-declared on each side.\n */\n\n// Session identity. Branded so a session ID is not interchangeable with an\n// entry, part, or workspace ID at the type level — service signatures take\n// `SessionID`, never a bare `string`.\n//\n// `create` mints a new one; `ascending` adopts an ID that came from outside\n// (a persisted row, a request payload) and rejects a foreign prefix rather\n// than branding it silently. uuidv7 keeps IDs lexicographically sortable by\n// creation time, so `ORDER BY id` is `ORDER BY created`.\nexport const SessionID = Schema.String.check(Schema.isStartsWith(\"ses\")).pipe(\n\tSchema.brand(\"Session.ID\"),\n\twithStatics((schema) => ({\n\t\tascending: (id?: string) => {\n\t\t\tif (!id) return schema.make(\"ses_\" + uuidv7());\n\t\t\tif (!id.startsWith(\"ses\")) throw new Error(`ID ${id} does not start with ses`);\n\t\t\treturn schema.make(id);\n\t\t},\n\t\tcreate: () => schema.make(\"ses_\" + uuidv7()),\n\t})),\n);\nexport type SessionID = typeof SessionID.Type;\n\n/**\n * A conversation message id.\n *\n * Deliberately unprefixed. aikit mints assistant message ids itself, as bare\n * uuidv7, and `stream()` accepts no id -- so any naming rule of ours would have\n * to be imposed on messages aikit hands us, by rewriting a field of the value we\n * were given. Sharing aikit's format instead means an id means the same thing on\n * both sides of the boundary and never needs translating.\n *\n * The brand carries the meaning; uuidv7 keeps ids time-ordered, so they sort by\n * creation.\n */\nexport const MessageID = Schema.String.pipe(\n\tSchema.brand(\"Message.ID\"),\n\twithStatics((schema) => ({\n\t\tcreate: () => schema.make(uuidv7()),\n\t\t/**\n\t\t * Adopt an id minted elsewhere -- in practice aikit's, which arrives as a\n\t\t * plain string on every stream event and inside every assistant message.\n\t\t *\n\t\t * `make` does the same thing. This exists so the boundary where a foreign\n\t\t * id enters the domain is named and greppable, and so the pairing with\n\t\t * `create` says which side chose the id.\n\t\t */\n\t\tfrom: (id: string) => schema.make(id),\n\t})),\n);\nexport type MessageID = typeof MessageID.Type;\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAa,YAAY,OAAO,OAAO,MAAM,OAAO,aAAa,KAAK,CAAC,CAAC,CAAC,KACxE,OAAO,MAAM,YAAY,GACzB,aAAa,YAAY;CACxB,YAAY,OAAgB;EAC3B,IAAI,CAAC,IAAI,OAAO,OAAO,KAAK,SAAS,OAAO,CAAC;EAC7C,IAAI,CAAC,GAAG,WAAW,KAAK,GAAG,MAAM,IAAI,MAAM,MAAM,GAAG,yBAAyB;EAC7E,OAAO,OAAO,KAAK,EAAE;CACtB;CACA,cAAc,OAAO,KAAK,SAAS,OAAO,CAAC;AAC5C,EAAE,CACH;;;;;;;;;;;;;AAeA,MAAa,YAAY,OAAO,OAAO,KACtC,OAAO,MAAM,YAAY,GACzB,aAAa,YAAY;CACxB,cAAc,OAAO,KAAK,OAAO,CAAC;;;;;;;;;CASlC,OAAO,OAAe,OAAO,KAAK,EAAE;AACrC,EAAE,CACH"}
package/index.d.mts ADDED
@@ -0,0 +1,3 @@
1
+ import { g as tool_d_exports } from "./tool-DuYBgiJf.mjs";
2
+ import { t as plugin_d_exports } from "./plugin-DbJEpY3M.mjs";
3
+ export { plugin_d_exports as Plugin, tool_d_exports as Tool };
package/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { t as plugin_exports } from "./plugin-lorpq7Oi.mjs";
2
+ import { t as tool_exports } from "./tool.mjs";
3
+ export { plugin_exports as Plugin, tool_exports as Tool };