@onkeiki/agents 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 (111) hide show
  1. package/dist/Alert.d.ts +56 -0
  2. package/dist/Alert.d.ts.map +1 -0
  3. package/dist/Alert.js +8 -0
  4. package/dist/Alert.js.map +1 -0
  5. package/dist/Entity.d.ts +158 -0
  6. package/dist/Entity.d.ts.map +1 -0
  7. package/dist/Entity.js +289 -0
  8. package/dist/Entity.js.map +1 -0
  9. package/dist/Kit.d.ts +138 -0
  10. package/dist/Kit.d.ts.map +1 -0
  11. package/dist/Kit.js +517 -0
  12. package/dist/Kit.js.map +1 -0
  13. package/dist/OpenApi.d.ts +151 -0
  14. package/dist/OpenApi.d.ts.map +1 -0
  15. package/dist/OpenApi.js +222 -0
  16. package/dist/OpenApi.js.map +1 -0
  17. package/dist/Plugin.d.ts +183 -0
  18. package/dist/Plugin.d.ts.map +1 -0
  19. package/dist/Plugin.js +10 -0
  20. package/dist/Plugin.js.map +1 -0
  21. package/dist/Server.d.ts +71 -0
  22. package/dist/Server.d.ts.map +1 -0
  23. package/dist/Server.js +476 -0
  24. package/dist/Server.js.map +1 -0
  25. package/dist/Tool.d.ts +86 -0
  26. package/dist/Tool.d.ts.map +1 -0
  27. package/dist/Tool.js +27 -0
  28. package/dist/Tool.js.map +1 -0
  29. package/dist/bundle.d.ts +17 -0
  30. package/dist/bundle.d.ts.map +1 -0
  31. package/dist/bundle.js +101 -0
  32. package/dist/bundle.js.map +1 -0
  33. package/dist/index.d.ts +19 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +18 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/services/Blackboard.d.ts +18 -0
  38. package/dist/services/Blackboard.d.ts.map +1 -0
  39. package/dist/services/Blackboard.js +4 -0
  40. package/dist/services/Blackboard.js.map +1 -0
  41. package/dist/services/Observability.d.ts +102 -0
  42. package/dist/services/Observability.d.ts.map +1 -0
  43. package/dist/services/Observability.js +238 -0
  44. package/dist/services/Observability.js.map +1 -0
  45. package/dist/services/Platform.d.ts +112 -0
  46. package/dist/services/Platform.d.ts.map +1 -0
  47. package/dist/services/Platform.js +13 -0
  48. package/dist/services/Platform.js.map +1 -0
  49. package/dist/services/PluginDb.d.ts +44 -0
  50. package/dist/services/PluginDb.d.ts.map +1 -0
  51. package/dist/services/PluginDb.js +5 -0
  52. package/dist/services/PluginDb.js.map +1 -0
  53. package/dist/services/Sandbox.d.ts +68 -0
  54. package/dist/services/Sandbox.d.ts.map +1 -0
  55. package/dist/services/Sandbox.js +4 -0
  56. package/dist/services/Sandbox.js.map +1 -0
  57. package/dist/services/Steering.d.ts +46 -0
  58. package/dist/services/Steering.d.ts.map +1 -0
  59. package/dist/services/Steering.js +4 -0
  60. package/dist/services/Steering.js.map +1 -0
  61. package/dist/services/Storage.d.ts +63 -0
  62. package/dist/services/Storage.d.ts.map +1 -0
  63. package/dist/services/Storage.js +13 -0
  64. package/dist/services/Storage.js.map +1 -0
  65. package/dist/services/Transport.d.ts +19 -0
  66. package/dist/services/Transport.d.ts.map +1 -0
  67. package/dist/services/Transport.js +4 -0
  68. package/dist/services/Transport.js.map +1 -0
  69. package/dist/services/index.d.ts +9 -0
  70. package/dist/services/index.d.ts.map +1 -0
  71. package/dist/services/index.js +9 -0
  72. package/dist/services/index.js.map +1 -0
  73. package/dist/types/config.d.ts +526 -0
  74. package/dist/types/config.d.ts.map +1 -0
  75. package/dist/types/config.js +2 -0
  76. package/dist/types/config.js.map +1 -0
  77. package/dist/types/index.d.ts +4 -0
  78. package/dist/types/index.d.ts.map +1 -0
  79. package/dist/types/index.js +4 -0
  80. package/dist/types/index.js.map +1 -0
  81. package/dist/types/message.d.ts +54 -0
  82. package/dist/types/message.d.ts.map +1 -0
  83. package/dist/types/message.js +47 -0
  84. package/dist/types/message.js.map +1 -0
  85. package/dist/types/user.d.ts +16 -0
  86. package/dist/types/user.d.ts.map +1 -0
  87. package/dist/types/user.js +14 -0
  88. package/dist/types/user.js.map +1 -0
  89. package/package.json +39 -0
  90. package/src/Alert.ts +51 -0
  91. package/src/Entity.ts +543 -0
  92. package/src/Kit.ts +705 -0
  93. package/src/OpenApi.ts +343 -0
  94. package/src/Plugin.ts +209 -0
  95. package/src/Server.ts +618 -0
  96. package/src/Tool.ts +110 -0
  97. package/src/bundle.ts +114 -0
  98. package/src/index.ts +209 -0
  99. package/src/services/Blackboard.ts +19 -0
  100. package/src/services/Observability.ts +320 -0
  101. package/src/services/Platform.ts +125 -0
  102. package/src/services/PluginDb.ts +48 -0
  103. package/src/services/Sandbox.ts +74 -0
  104. package/src/services/Steering.ts +45 -0
  105. package/src/services/Storage.ts +76 -0
  106. package/src/services/Transport.ts +21 -0
  107. package/src/services/index.ts +8 -0
  108. package/src/types/config.ts +531 -0
  109. package/src/types/index.ts +3 -0
  110. package/src/types/message.ts +60 -0
  111. package/src/types/user.ts +17 -0
@@ -0,0 +1,238 @@
1
+ /**
2
+ * Observability Service
3
+ *
4
+ * Allows developers to export turn traces to external providers:
5
+ * - Braintrust (AI-specific tracing, evals, scoring)
6
+ * - Axiom (structured log ingestion)
7
+ * - Generic OTEL (any OpenTelemetry-compatible backend)
8
+ * - Custom (developer-provided exporter function)
9
+ *
10
+ * The platform always records traces internally (14-day retention).
11
+ * This service ADDITIONALLY exports to the developer's chosen provider.
12
+ */
13
+ import { Effect, Context } from 'effect';
14
+ export class ObservabilityError {
15
+ provider;
16
+ message;
17
+ cause;
18
+ _tag = 'ObservabilityError';
19
+ constructor(provider, message, cause) {
20
+ this.provider = provider;
21
+ this.message = message;
22
+ this.cause = cause;
23
+ }
24
+ }
25
+ // --- Service Tag ---
26
+ export class Observability extends Context.Tag('Observability')() {
27
+ }
28
+ // --- Provider Factories ---
29
+ /**
30
+ * Braintrust exporter.
31
+ * Sends traces as Braintrust spans for AI observability, evals, and scoring.
32
+ */
33
+ export function braintrustExporter(config) {
34
+ const baseUrl = config.baseUrl ?? 'https://api.braintrust.dev';
35
+ return {
36
+ name: 'braintrust',
37
+ exportTrace: (trace) => Effect.tryPromise({
38
+ try: async () => {
39
+ const spans = trace.spans.map((span) => ({
40
+ id: span.spanId,
41
+ span_id: span.spanId,
42
+ root_span_id: trace.traceId,
43
+ parent_id: span.parentSpanId,
44
+ name: span.name,
45
+ kind: mapSpanKindToBraintrust(span.kind),
46
+ start_time: span.startedAt.toISOString(),
47
+ end_time: span.endedAt?.toISOString(),
48
+ status_code: span.status === 'error' ? 'ERROR' : 'OK',
49
+ input: span.input,
50
+ output: span.output,
51
+ error: span.error,
52
+ metadata: {
53
+ ...span.metadata,
54
+ kind: span.kind,
55
+ phone: trace.phone,
56
+ },
57
+ metrics: span.kind === 'llm' ? {
58
+ tokens: (trace.tokensIn + trace.tokensOut) || undefined,
59
+ prompt_tokens: trace.tokensIn || undefined,
60
+ completion_tokens: trace.tokensOut || undefined,
61
+ } : undefined,
62
+ }));
63
+ const res = await fetch(`${baseUrl}/v1/project_logs/${encodeURIComponent(config.projectName)}/insert`, {
64
+ method: 'POST',
65
+ headers: {
66
+ 'Authorization': `Bearer ${config.apiKey}`,
67
+ 'Content-Type': 'application/json',
68
+ },
69
+ body: JSON.stringify({ events: spans }),
70
+ });
71
+ if (!res.ok) {
72
+ throw new Error(`Braintrust export failed: ${res.status} ${await res.text()}`);
73
+ }
74
+ },
75
+ catch: (err) => new ObservabilityError('braintrust', String(err), err),
76
+ }),
77
+ };
78
+ }
79
+ /**
80
+ * Axiom exporter.
81
+ * Sends traces as structured events to an Axiom dataset.
82
+ */
83
+ export function axiomExporter(config) {
84
+ const baseUrl = config.baseUrl ?? 'https://api.axiom.co';
85
+ return {
86
+ name: 'axiom',
87
+ exportTrace: (trace) => Effect.tryPromise({
88
+ try: async () => {
89
+ // Flatten trace + spans into Axiom events
90
+ const events = [
91
+ // Root trace event
92
+ {
93
+ _time: trace.startedAt.toISOString(),
94
+ type: 'trace',
95
+ traceId: trace.traceId,
96
+ apiKey: trace.apiKey,
97
+ phone: trace.phone,
98
+ model: trace.model,
99
+ status: trace.status,
100
+ durationMs: trace.durationMs,
101
+ tokensIn: trace.tokensIn,
102
+ tokensOut: trace.tokensOut,
103
+ totalSteps: trace.totalSteps,
104
+ error: trace.error,
105
+ ...trace.metadata,
106
+ },
107
+ // Individual span events
108
+ ...trace.spans.map((span) => ({
109
+ _time: span.startedAt.toISOString(),
110
+ type: 'span',
111
+ traceId: span.traceId,
112
+ spanId: span.spanId,
113
+ parentSpanId: span.parentSpanId,
114
+ name: span.name,
115
+ kind: span.kind,
116
+ status: span.status,
117
+ durationMs: span.durationMs,
118
+ error: span.error,
119
+ ...span.metadata,
120
+ })),
121
+ ];
122
+ const res = await fetch(`${baseUrl}/v1/datasets/${config.dataset}/ingest`, {
123
+ method: 'POST',
124
+ headers: {
125
+ 'Authorization': `Bearer ${config.apiToken}`,
126
+ 'Content-Type': 'application/json',
127
+ ...(config.orgId ? { 'X-Axiom-Org-Id': config.orgId } : {}),
128
+ },
129
+ body: JSON.stringify(events),
130
+ });
131
+ if (!res.ok) {
132
+ throw new Error(`Axiom export failed: ${res.status} ${await res.text()}`);
133
+ }
134
+ },
135
+ catch: (err) => new ObservabilityError('axiom', String(err), err),
136
+ }),
137
+ };
138
+ }
139
+ /**
140
+ * OpenTelemetry (OTLP) exporter.
141
+ * Sends traces via OTLP/HTTP (JSON) to any OTEL-compatible backend
142
+ * (Grafana Tempo, Jaeger, Honeycomb, Datadog, etc.)
143
+ */
144
+ export function otelExporter(config) {
145
+ const serviceName = config.serviceName ?? 'orchid-sms-agent';
146
+ return {
147
+ name: 'otel',
148
+ exportTrace: (trace) => Effect.tryPromise({
149
+ try: async () => {
150
+ const resourceSpans = [{
151
+ resource: {
152
+ attributes: [
153
+ { key: 'service.name', value: { stringValue: serviceName } },
154
+ { key: 'orchid.api_key', value: { stringValue: trace.apiKey } },
155
+ ],
156
+ },
157
+ scopeSpans: [{
158
+ scope: { name: 'orchid-agents', version: '0.1.0' },
159
+ spans: trace.spans.map((span) => ({
160
+ traceId: hexToBase64(trace.traceId),
161
+ spanId: hexToBase64(span.spanId.replace(/-/g, '').slice(0, 16)),
162
+ parentSpanId: span.parentSpanId ? hexToBase64(span.parentSpanId.replace(/-/g, '').slice(0, 16)) : undefined,
163
+ name: span.name,
164
+ kind: mapSpanKindToOtel(span.kind),
165
+ startTimeUnixNano: String(span.startedAt.getTime() * 1_000_000),
166
+ endTimeUnixNano: span.endedAt ? String(span.endedAt.getTime() * 1_000_000) : undefined,
167
+ status: {
168
+ code: span.status === 'error' ? 2 : 1,
169
+ message: span.error,
170
+ },
171
+ attributes: [
172
+ { key: 'orchid.span.kind', value: { stringValue: span.kind } },
173
+ { key: 'orchid.phone', value: { stringValue: trace.phone } },
174
+ ...(span.kind === 'llm' ? [
175
+ { key: 'gen_ai.system', value: { stringValue: 'orchid' } },
176
+ { key: 'gen_ai.request.model', value: { stringValue: trace.model ?? '' } },
177
+ { key: 'gen_ai.usage.prompt_tokens', value: { intValue: String(trace.tokensIn) } },
178
+ { key: 'gen_ai.usage.completion_tokens', value: { intValue: String(trace.tokensOut) } },
179
+ ] : []),
180
+ ],
181
+ })),
182
+ }],
183
+ }];
184
+ const res = await fetch(`${config.endpoint}/v1/traces`, {
185
+ method: 'POST',
186
+ headers: {
187
+ 'Content-Type': 'application/json',
188
+ ...config.headers,
189
+ },
190
+ body: JSON.stringify({ resourceSpans }),
191
+ });
192
+ if (!res.ok) {
193
+ throw new Error(`OTEL export failed: ${res.status} ${await res.text()}`);
194
+ }
195
+ },
196
+ catch: (err) => new ObservabilityError('otel', String(err), err),
197
+ }),
198
+ };
199
+ }
200
+ /**
201
+ * Custom exporter — developer provides their own export function.
202
+ */
203
+ export function customExporter(config) {
204
+ return {
205
+ name: config.name,
206
+ exportTrace: (trace) => Effect.tryPromise({
207
+ try: () => config.exportFn(trace),
208
+ catch: (err) => new ObservabilityError(config.name, String(err), err),
209
+ }),
210
+ };
211
+ }
212
+ // --- Helpers ---
213
+ function mapSpanKindToBraintrust(kind) {
214
+ switch (kind) {
215
+ case 'llm': return 'llm';
216
+ case 'tool': return 'tool';
217
+ case 'retrieval': return 'retrieval';
218
+ case 'generation': return 'generation';
219
+ default: return 'task';
220
+ }
221
+ }
222
+ function mapSpanKindToOtel(kind) {
223
+ switch (kind) {
224
+ case 'llm': return 3; // CLIENT
225
+ case 'tool': return 3; // CLIENT
226
+ case 'retrieval': return 3; // CLIENT
227
+ case 'internal': return 1; // INTERNAL
228
+ default: return 0; // UNSPECIFIED
229
+ }
230
+ }
231
+ function hexToBase64(hex) {
232
+ const bytes = new Uint8Array(hex.length / 2);
233
+ for (let i = 0; i < hex.length; i += 2) {
234
+ bytes[i / 2] = parseInt(hex.slice(i, i + 2), 16);
235
+ }
236
+ return btoa(String.fromCharCode(...bytes));
237
+ }
238
+ //# sourceMappingURL=Observability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Observability.js","sourceRoot":"","sources":["../../src/services/Observability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAiDxC,MAAM,OAAO,kBAAkB;IAER,QAAQ;IAAmB,OAAO;IAAmB,KAAK;IADtE,IAAI,GAAG,oBAAoB,CAAA;IACpC,YAAqB,QAAgB,EAAW,OAAe,EAAW,KAAe;wBAApE,QAAQ;uBAAmB,OAAO;qBAAmB,KAAK;IAAa,CAAC;CAC9F;AAED,sBAAsB;AAEtB,MAAM,OAAO,aAAc,SAAQ,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,EAG5D;CAAG;AAEN,6BAA6B;AAE7B;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAIlC;IACC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,4BAA4B,CAAA;IAE9D,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,CACrB,MAAM,CAAC,UA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AC;AAED,kBAAkB;AAElB,SAAS,uBAAuB,CAAC,IAAc;IAC7C,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,KAAK,EAAE,OAAO,KAAK,CAAA;QACxB,KAAK,MAAM,EAAE,OAAO,MAAM,CAAA;QAC1B,KAAK,WAAW,EAAE,OAAO,WAAW,CAAA;QACpC,KAAK,YAAY,EAAE,OAAO,YAAY,CAAA;QACtC,SAAS,OAAO,MAAM,CAAA;IACxB,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAc;IACvC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,KAAK,EAAE,OAAO,CAAC,CAAA,CAAC,SAAS;QAC9B,KAAK,MAAM,EAAE,OAAO,CAAC,CAAA,CAAC,SAAS;QAC/B,KAAK,WAAW,EAAE,OAAO,CAAC,CAAA,CAAC,SAAS;QACpC,KAAK,UAAU,EAAE,OAAO,CAAC,CAAA,CAAC,WAAW;QACrC,SAAS,OAAO,CAAC,CAAA,CAAC,cAAc;IAClC,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAClD,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,CAAC,CAAA;AAC5C,CAAC"}
@@ -0,0 +1,112 @@
1
+ import { Context, Effect } from 'effect';
2
+ export declare class PlatformError {
3
+ readonly message: string;
4
+ readonly cause?: unknown;
5
+ readonly _tag = "PlatformError";
6
+ constructor(message: string, cause?: unknown);
7
+ }
8
+ /**
9
+ * Platform client — communicates with the Orchid platform API
10
+ * to access managed services (memory, browser, sandbox, etc.)
11
+ */
12
+ export type MemoryFact = {
13
+ readonly id: string;
14
+ readonly content: string;
15
+ readonly category: string;
16
+ readonly createdAt: Date;
17
+ };
18
+ export type BrowseResult = {
19
+ readonly sessionId: string;
20
+ readonly url: string;
21
+ readonly screenshot?: string;
22
+ readonly content?: string;
23
+ };
24
+ export type SandboxExecResult = {
25
+ readonly stdout: string;
26
+ readonly stderr: string;
27
+ readonly exitCode: number;
28
+ readonly files?: ReadonlyArray<{
29
+ path: string;
30
+ url: string;
31
+ }>;
32
+ };
33
+ export type HandoffResult = {
34
+ readonly handoffUrl: string;
35
+ readonly sessionId: string;
36
+ readonly status: 'waiting' | 'completed' | 'expired';
37
+ };
38
+ export type EscalationResult = {
39
+ readonly escalationId: string;
40
+ readonly routedTo: string;
41
+ readonly status: 'pending' | 'acknowledged' | 'resolved';
42
+ };
43
+ export type BackgroundJobResult = {
44
+ readonly jobId: string;
45
+ readonly status: 'queued' | 'running' | 'completed' | 'failed';
46
+ readonly result?: unknown;
47
+ };
48
+ export interface PlatformService {
49
+ readonly memoryRecall: (phone: string, query: string, opts?: {
50
+ categories?: ReadonlyArray<string>;
51
+ limit?: number;
52
+ }) => Effect.Effect<ReadonlyArray<MemoryFact>, PlatformError>;
53
+ readonly memoryLearn: (phone: string, facts: ReadonlyArray<{
54
+ content: string;
55
+ category: string;
56
+ }>) => Effect.Effect<void, PlatformError>;
57
+ readonly browse: (instruction: string, opts?: {
58
+ sessionId?: string;
59
+ screenshot?: boolean;
60
+ }) => Effect.Effect<BrowseResult, PlatformError>;
61
+ readonly handoff: (opts: {
62
+ phone: string;
63
+ instruction: string;
64
+ url?: string;
65
+ timeoutMinutes?: number;
66
+ }) => Effect.Effect<HandoffResult, PlatformError>;
67
+ readonly exec: (command: string, opts?: {
68
+ phone?: string;
69
+ persistent?: boolean;
70
+ timeout?: number;
71
+ }) => Effect.Effect<SandboxExecResult, PlatformError>;
72
+ readonly writeFile: (path: string, content: string, opts?: {
73
+ phone?: string;
74
+ }) => Effect.Effect<void, PlatformError>;
75
+ readonly readFile: (path: string, opts?: {
76
+ phone?: string;
77
+ }) => Effect.Effect<string, PlatformError>;
78
+ readonly runJob: (opts: {
79
+ name: string;
80
+ command: string;
81
+ phone?: string;
82
+ timeout?: number;
83
+ }) => Effect.Effect<BackgroundJobResult, PlatformError>;
84
+ readonly getJobStatus: (jobId: string) => Effect.Effect<BackgroundJobResult, PlatformError>;
85
+ readonly escalate: (opts: {
86
+ phone: string;
87
+ reason: string;
88
+ context?: string;
89
+ routes?: {
90
+ webhook?: string;
91
+ slack?: {
92
+ channel: string;
93
+ };
94
+ email?: string;
95
+ };
96
+ }) => Effect.Effect<EscalationResult, PlatformError>;
97
+ readonly extractFacts: (phone: string, messages: ReadonlyArray<{
98
+ content: string;
99
+ direction: 'inbound' | 'outbound';
100
+ }>) => Effect.Effect<ReadonlyArray<{
101
+ content: string;
102
+ category: string;
103
+ }>, PlatformError>;
104
+ readonly transcribeAudio: (url: string) => Effect.Effect<string, PlatformError>;
105
+ readonly describeImage: (url: string, prompt?: string) => Effect.Effect<string, PlatformError>;
106
+ readonly extractDocument: (url: string) => Effect.Effect<string, PlatformError>;
107
+ }
108
+ declare const Platform_base: Context.TagClass<Platform, "@onkeiki/agents/Platform", PlatformService>;
109
+ export declare class Platform extends Platform_base {
110
+ }
111
+ export {};
112
+ //# sourceMappingURL=Platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Platform.d.ts","sourceRoot":"","sources":["../../src/services/Platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAExC,qBAAa,aAAa;IAEZ,QAAQ,CAAC,OAAO,EAAE,MAAM;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO;IAD9D,QAAQ,C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AAC,EAAE;gBAAE,OAAO,EAAE,MAAM,CAAA;aAAE,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAC3E,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAA;IAGpD,QAAQ,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC;QAC7D,OAAO,EAAE,MAAM,CAAA;QACf,SAAS,EAAE,SAAS,GAAG,UAAU,CAAA;KAClC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,aAAa,CAAC,CAAA;IAGzF,QAAQ,CAAC,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC/E,QAAQ,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC9F,QAAQ,CAAC,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;CAChF;;AAED,qBAAa,QAAS,SAAQ,aAG3B;CAAG"}
@@ -0,0 +1,13 @@
1
+ import { Context, Effect } from 'effect';
2
+ export class PlatformError {
3
+ message;
4
+ cause;
5
+ _tag = 'PlatformError';
6
+ constructor(message, cause) {
7
+ this.message = message;
8
+ this.cause = cause;
9
+ }
10
+ }
11
+ export class Platform extends Context.Tag('@onkeiki/agents/Platform')() {
12
+ }
13
+ //# sourceMappingURL=Platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Platform.js","sourceRoot":"","sources":["../../src/services/Platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAExC,MAAM,OAAO,aAAa;IAEH,OAAO;IAAmB,KAAK;IAD3C,IAAI,GAAG,eAAe,CAAA;IAC/B,YAAqB,OAAe,EAAW,KAAe;uBAAzC,OAAO;qBAAmB,KAAK;IAAa,CAAC;CACnE;AAoHD,MAAM,OAAO,QAAS,SAAQ,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,EAGlE;CAAG"}
@@ -0,0 +1,44 @@
1
+ import { Context, Effect } from 'effect';
2
+ import { StorageError } from './Storage.js';
3
+ /**
4
+ * Generic query interface for plugins that need their own persistence.
5
+ *
6
+ * Provided by the active storage adapter (Postgres, MongoDB, etc.) so
7
+ * plugins can create and query their own tables/collections without
8
+ * extending the core `StorageService` interface.
9
+ *
10
+ * The storage adapter is responsible for:
11
+ * - Running plugin migrations at boot (see `PluginMigration`)
12
+ * - Providing a `PluginDb` backed by the same connection pool / client
13
+ *
14
+ * Plugins access this via `PluginDb` in their tools and hooks.
15
+ */
16
+ export interface PluginDbService {
17
+ /** Run a query that returns rows. */
18
+ readonly query: <T = Record<string, unknown>>(sql: string, params?: readonly unknown[]) => Effect.Effect<T[], StorageError>;
19
+ /** Run a query that returns a single row or null. */
20
+ readonly queryOne: <T = Record<string, unknown>>(sql: string, params?: readonly unknown[]) => Effect.Effect<T | null, StorageError>;
21
+ /** Run a statement that doesn't return rows (INSERT, UPDATE, DELETE). */
22
+ readonly execute: (sql: string, params?: readonly unknown[]) => Effect.Effect<void, StorageError>;
23
+ }
24
+ declare const PluginDb_base: Context.TagClass<PluginDb, "@onkeiki/agents/PluginDb", PluginDbService>;
25
+ export declare class PluginDb extends PluginDb_base {
26
+ }
27
+ /**
28
+ * A single migration contributed by a plugin. Migrations are tracked in
29
+ * a `smskit_plugin_migrations` table and only run once per (pluginId, version).
30
+ *
31
+ * Migrations are NEVER rolled back when a plugin is disabled — disabling
32
+ * a plugin simply stops running its code, but the tables and data remain
33
+ * intact. This prevents accidental data loss.
34
+ */
35
+ export type PluginMigration = {
36
+ /** Monotonically increasing version number (1, 2, 3, ...). */
37
+ readonly version: number;
38
+ /** Human-readable name for logging. */
39
+ readonly name: string;
40
+ /** SQL statement(s) to execute. May contain multiple statements separated by semicolons. */
41
+ readonly up: string;
42
+ };
43
+ export {};
44
+ //# sourceMappingURL=PluginDb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginDb.d.ts","sourceRoot":"","sources":["../../src/services/PluginDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,eAAe;IAC9B,qCAAqC;IACrC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,YAAY,CAAC,CAAA;IAE3H,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,EAAE,YAAY,CAAC,CAAA;IAEnI,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;CAClG;;AAED,qBAAa,QAAS,SAAQ,aAG3B;CAAG;AAEN;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CACpB,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { Context, Effect } from 'effect';
2
+ import { StorageError } from './Storage.js';
3
+ export class PluginDb extends Context.Tag('@onkeiki/agents/PluginDb')() {
4
+ }
5
+ //# sourceMappingURL=PluginDb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginDb.js","sourceRoot":"","sources":["../../src/services/PluginDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AA0B3C,MAAM,OAAO,QAAS,SAAQ,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,EAGlE;CAAG"}
@@ -0,0 +1,68 @@
1
+ import { Context } from 'effect';
2
+ /**
3
+ * Result of executing a command in a sandbox.
4
+ */
5
+ export type SandboxExecResult = {
6
+ readonly stdout: string;
7
+ readonly stderr: string;
8
+ readonly exitCode: number;
9
+ };
10
+ /**
11
+ * A handle to a running sandbox instance. Provides shell execution and
12
+ * network access needed by plugins that run daemons inside sandboxes
13
+ * (e.g. Executor.sh for custom MCP servers).
14
+ */
15
+ export interface SandboxHandle {
16
+ /** Execute a shell command inside the sandbox. */
17
+ readonly exec: (command: string, opts?: {
18
+ readonly timeoutSeconds?: number;
19
+ readonly cwd?: string;
20
+ }) => Promise<SandboxExecResult>;
21
+ /** Get a publicly-reachable URL for a port exposed inside the sandbox. */
22
+ readonly getPublicUrl: (port: number, expiresInSeconds?: number) => Promise<string>;
23
+ /** Absolute home directory of the sandbox user. */
24
+ readonly getHomeDir: () => Promise<string>;
25
+ /**
26
+ * Absolute path of a durable data directory backed by persistent storage
27
+ * (e.g. a Daytona volume) that survives sandbox stop/delete, or `null` when
28
+ * no durable storage is attached. Daemons that keep state (SQLite, OAuth
29
+ * credentials) use it as a backup/restore target across sandbox recreation.
30
+ */
31
+ readonly getPersistentExecutorDataDir?: () => Promise<string | null>;
32
+ }
33
+ /**
34
+ * Abstract sandbox provider — any sandbox company (Daytona, E2B, Runloop,
35
+ * Modal, etc.) can implement this interface and plug into AgentKit.
36
+ *
37
+ * The provider is responsible for lifecycle management (create, start, stop,
38
+ * reuse) of sandboxes. Each `scope` string identifies an isolation boundary
39
+ * (e.g. `"apiKey:phone"` for per-user sandboxes).
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * // Community adapter: @onkeiki/agents-sandbox-daytona
44
+ * import { Daytona } from '@daytona/sdk'
45
+ *
46
+ * export function daytona(opts: { apiKey: string; snapshot?: string }): SandboxProvider {
47
+ * return {
48
+ * resolve: async (scope) => {
49
+ * const sandbox = await getOrCreate(scope)
50
+ * return {
51
+ * exec: (cmd, o) => sandbox.process.executeCommand(cmd, o?.cwd, {}, o?.timeoutSeconds),
52
+ * getPublicUrl: (port, exp) => sandbox.getSignedPreviewUrl(port, exp).then(r => r.url),
53
+ * getHomeDir: () => sandbox.getUserHomeDir().then(h => h ?? '/root'),
54
+ * }
55
+ * },
56
+ * }
57
+ * }
58
+ * ```
59
+ */
60
+ export interface SandboxProviderService {
61
+ /** Get or create a sandbox for the given scope. */
62
+ readonly resolve: (scope: string) => Promise<SandboxHandle>;
63
+ }
64
+ declare const SandboxProvider_base: Context.TagClass<SandboxProvider, "@onkeiki/agents/SandboxProvider", SandboxProviderService>;
65
+ export declare class SandboxProvider extends SandboxProvider_base {
66
+ }
67
+ export {};
68
+ //# sourceMappingURL=Sandbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sandbox.d.ts","sourceRoot":"","sources":["../../src/services/Sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAEhC;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,CACb,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,KAC/D,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAE/B,0EAA0E;IAC1E,QAAQ,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IAEnF,mDAAmD;IACnD,QAAQ,CAAC,UAAU,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IAE1C;;;;;OAKG;IACH,QAAQ,CAAC,4BAA4B,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;CACrE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,sBAAsB;IACrC,mDAAmD;IACnD,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAA;CAC5D;;AAED,qBAAa,eAAgB,SAAQ,oBAGlC;CAAG"}
@@ -0,0 +1,4 @@
1
+ import { Context } from 'effect';
2
+ export class SandboxProvider extends Context.Tag('@onkeiki/agents/SandboxProvider')() {
3
+ }
4
+ //# sourceMappingURL=Sandbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sandbox.js","sourceRoot":"","sources":["../../src/services/Sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAsEhC,MAAM,OAAO,eAAgB,SAAQ,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,EAGhF;CAAG"}
@@ -0,0 +1,46 @@
1
+ import { Context, Effect, Queue } from 'effect';
2
+ import type { InboundMessage } from '../types/index.js';
3
+ export type SteeringDecision = {
4
+ readonly type: 'batch';
5
+ readonly messages: ReadonlyArray<InboundMessage>;
6
+ } | {
7
+ readonly type: 'interrupt';
8
+ readonly messages: ReadonlyArray<InboundMessage>;
9
+ } | {
10
+ readonly type: 'append';
11
+ readonly message: InboundMessage;
12
+ } | {
13
+ readonly type: 'queue';
14
+ readonly message: InboundMessage;
15
+ };
16
+ export type TurnState = {
17
+ readonly phone: string;
18
+ readonly status: 'idle' | 'debouncing' | 'processing';
19
+ readonly pending: ReadonlyArray<InboundMessage>;
20
+ readonly currentTurnStartedAt?: Date;
21
+ };
22
+ export interface SteeringService {
23
+ /**
24
+ * Enqueue an inbound message. Steering decides when to
25
+ * release it as a turn (after debounce window) or interrupt
26
+ * an in-progress turn.
27
+ */
28
+ readonly enqueue: (msg: InboundMessage) => Effect.Effect<void>;
29
+ /**
30
+ * Subscribe to turn decisions. The agent runtime consumes these.
31
+ */
32
+ readonly decisions: Effect.Effect<Queue.Dequeue<SteeringDecision>>;
33
+ /**
34
+ * Signal that the current turn for a phone has completed.
35
+ */
36
+ readonly turnCompleted: (phone: string) => Effect.Effect<void>;
37
+ /**
38
+ * Get current state for a phone number.
39
+ */
40
+ readonly getState: (phone: string) => Effect.Effect<TurnState>;
41
+ }
42
+ declare const Steering_base: Context.TagClass<Steering, "@onkeiki/agents/Steering", SteeringService>;
43
+ export declare class Steering extends Steering_base {
44
+ }
45
+ export {};
46
+ //# sourceMappingURL=Steering.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Steering.d.ts","sourceRoot":"","sources":["../../src/services/Steering.ts"],"names":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CAAC,IAAI,CAAC,CAAA;IAE9D;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;CAC/D;;AAED,qBAAa,QAAS,SAAQ,aAG3B;CAAG"}
@@ -0,0 +1,4 @@
1
+ import { Context, Effect, Queue, Fiber, Ref } from 'effect';
2
+ export class Steering extends Context.Tag('@onkeiki/agents/Steering')() {
3
+ }
4
+ //# sourceMappingURL=Steering.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Steering.js","sourceRoot":"","sources":["../../src/services/Steering.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAyC3D,MAAM,OAAO,QAAS,SAAQ,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,EAGlE;CAAG"}