@on-mission/sdk 0.1.3 → 0.1.4
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.
- package/dist/auth-failure-tracker.d.ts +22 -0
- package/dist/auth-failure-tracker.d.ts.map +1 -0
- package/dist/auth-failure-tracker.js +31 -0
- package/dist/auth-failure-tracker.js.map +1 -0
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/context.js +1 -1
- package/dist/event-handler.d.ts +16 -0
- package/dist/event-handler.d.ts.map +1 -0
- package/dist/event-handler.js +27 -0
- package/dist/event-handler.js.map +1 -0
- package/dist/http-server.d.ts +2 -2
- package/dist/http-server.js +2 -2
- package/dist/index.d.ts +24 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/ingress.d.ts +2 -2
- package/dist/ingress.js +2 -2
- package/dist/logging.d.ts +2 -1
- package/dist/logging.d.ts.map +1 -1
- package/dist/logging.js +9 -1
- package/dist/logging.js.map +1 -1
- package/dist/sdk.d.ts +88 -10
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +122 -22
- package/dist/sdk.js.map +1 -1
- package/dist/tool-registry.d.ts +24 -4
- package/dist/tool-registry.d.ts.map +1 -1
- package/dist/tool-registry.js +3 -3
- package/dist/tool-registry.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/events.d.ts +0 -62
- package/dist/events.d.ts.map +0 -1
- package/dist/events.js +0 -30
- package/dist/events.js.map +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth Failure Tracker
|
|
3
|
+
*
|
|
4
|
+
* Tracks consecutive UNAUTHORIZED responses across all authenticated
|
|
5
|
+
* SDK operations (heartbeat, token refresh, log flush). After a
|
|
6
|
+
* configurable threshold of consecutive failures, fires a callback
|
|
7
|
+
* that the SDK uses to self-terminate via process.exit(1).
|
|
8
|
+
*
|
|
9
|
+
* This triggers Daytona's sandbox restart webhook, which runs the
|
|
10
|
+
* existing sandboxRestartWorkflow to re-provision the skill with
|
|
11
|
+
* a fresh JWT.
|
|
12
|
+
*
|
|
13
|
+
* Any successful authenticated call resets the counter to zero.
|
|
14
|
+
*/
|
|
15
|
+
export declare const AUTH_FAILURE_THRESHOLD = 3;
|
|
16
|
+
export type AuthFailureTracker = {
|
|
17
|
+
recordFailure: () => void;
|
|
18
|
+
recordSuccess: () => void;
|
|
19
|
+
getFailureCount: () => number;
|
|
20
|
+
};
|
|
21
|
+
export declare const createAuthFailureTracker: (onThresholdReached: () => void) => AuthFailureTracker;
|
|
22
|
+
//# sourceMappingURL=auth-failure-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-failure-tracker.d.ts","sourceRoot":"","sources":["../src/auth-failure-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,sBAAsB,IAAI,CAAA;AAEvC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,aAAa,EAAE,MAAM,IAAI,CAAA;IACzB,aAAa,EAAE,MAAM,IAAI,CAAA;IACzB,eAAe,EAAE,MAAM,MAAM,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,oBAAoB,MAAM,IAAI,KAC7B,kBAeF,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth Failure Tracker
|
|
3
|
+
*
|
|
4
|
+
* Tracks consecutive UNAUTHORIZED responses across all authenticated
|
|
5
|
+
* SDK operations (heartbeat, token refresh, log flush). After a
|
|
6
|
+
* configurable threshold of consecutive failures, fires a callback
|
|
7
|
+
* that the SDK uses to self-terminate via process.exit(1).
|
|
8
|
+
*
|
|
9
|
+
* This triggers Daytona's sandbox restart webhook, which runs the
|
|
10
|
+
* existing sandboxRestartWorkflow to re-provision the skill with
|
|
11
|
+
* a fresh JWT.
|
|
12
|
+
*
|
|
13
|
+
* Any successful authenticated call resets the counter to zero.
|
|
14
|
+
*/
|
|
15
|
+
export const AUTH_FAILURE_THRESHOLD = 3;
|
|
16
|
+
export const createAuthFailureTracker = (onThresholdReached) => {
|
|
17
|
+
const state = { consecutiveFailures: 0 };
|
|
18
|
+
return {
|
|
19
|
+
recordFailure: () => {
|
|
20
|
+
state.consecutiveFailures += 1;
|
|
21
|
+
if (state.consecutiveFailures >= AUTH_FAILURE_THRESHOLD) {
|
|
22
|
+
onThresholdReached();
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
recordSuccess: () => {
|
|
26
|
+
state.consecutiveFailures = 0;
|
|
27
|
+
},
|
|
28
|
+
getFailureCount: () => state.consecutiveFailures
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=auth-failure-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-failure-tracker.js","sourceRoot":"","sources":["../src/auth-failure-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAA;AAQvC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,kBAA8B,EACV,EAAE;IACtB,MAAM,KAAK,GAAG,EAAE,mBAAmB,EAAE,CAAC,EAAE,CAAA;IAExC,OAAO;QACL,aAAa,EAAE,GAAG,EAAE;YAClB,KAAK,CAAC,mBAAmB,IAAI,CAAC,CAAA;YAC9B,IAAI,KAAK,CAAC,mBAAmB,IAAI,sBAAsB,EAAE,CAAC;gBACxD,kBAAkB,EAAE,CAAA;YACtB,CAAC;QACH,CAAC;QACD,aAAa,EAAE,GAAG,EAAE;YAClB,KAAK,CAAC,mBAAmB,GAAG,CAAC,CAAA;QAC/B,CAAC;QACD,eAAe,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,mBAAmB;KACjD,CAAA;AACH,CAAC,CAAA"}
|
package/dist/auth.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Skill authors always call `auth.get()` regardless of auth type.
|
|
10
10
|
*
|
|
11
11
|
* For managed auth (Nango-backed), the SDK caches tokens and refreshes
|
|
12
|
-
* transparently. See docs/technical
|
|
12
|
+
* transparently. See docs/technical/architecture/skills/authentication.md.
|
|
13
13
|
*
|
|
14
14
|
* For custom auth, credentials are collected via a connection form
|
|
15
15
|
* defined in mission.json's `auth.credentials` schema.
|
package/dist/auth.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Skill authors always call `auth.get()` regardless of auth type.
|
|
10
10
|
*
|
|
11
11
|
* For managed auth (Nango-backed), the SDK caches tokens and refreshes
|
|
12
|
-
* transparently. See docs/technical
|
|
12
|
+
* transparently. See docs/technical/architecture/skills/authentication.md.
|
|
13
13
|
*
|
|
14
14
|
* For custom auth, credentials are collected via a connection form
|
|
15
15
|
* defined in mission.json's `auth.credentials` schema.
|
package/dist/config.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Accepts optional defaults so skills always get a complete config
|
|
6
6
|
* object without manual merging.
|
|
7
7
|
*
|
|
8
|
-
* The control plane stores config per
|
|
8
|
+
* The control plane stores config per Connection. Values are set
|
|
9
9
|
* by the user in the App's settings UI (defined by configSchema in
|
|
10
10
|
* mission.json). The SDK merges platform values over provided defaults
|
|
11
11
|
* so the returned object is always complete.
|
package/dist/config.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Accepts optional defaults so skills always get a complete config
|
|
6
6
|
* object without manual merging.
|
|
7
7
|
*
|
|
8
|
-
* The control plane stores config per
|
|
8
|
+
* The control plane stores config per Connection. Values are set
|
|
9
9
|
* by the user in the App's settings UI (defined by configSchema in
|
|
10
10
|
* mission.json). The SDK merges platform values over provided defaults
|
|
11
11
|
* so the returned object is always complete.
|
package/dist/context.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Bootstrapped from environment variables injected by the Mission control plane
|
|
5
5
|
* when it starts the skill process inside the Daytona sandbox.
|
|
6
6
|
*
|
|
7
|
-
* See docs/technical
|
|
7
|
+
* See docs/technical/architecture/skills/architecture.md §4.5.
|
|
8
8
|
*/
|
|
9
9
|
export type SkillContext = {
|
|
10
10
|
/** Mission control plane API base URL. */
|
package/dist/context.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Bootstrapped from environment variables injected by the Mission control plane
|
|
5
5
|
* when it starts the skill process inside the Daytona sandbox.
|
|
6
6
|
*
|
|
7
|
-
* See docs/technical
|
|
7
|
+
* See docs/technical/architecture/skills/architecture.md §4.5.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* Read skill context from process environment variables.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type SkillEvent = {
|
|
2
|
+
eventType: string;
|
|
3
|
+
payload: Record<string, unknown>;
|
|
4
|
+
platform: string;
|
|
5
|
+
tenantId: string;
|
|
6
|
+
};
|
|
7
|
+
export type EventHandler = (event: SkillEvent) => Promise<void> | void;
|
|
8
|
+
export type EventHandlerRegistry = {
|
|
9
|
+
on: (eventName: string, handler: EventHandler) => void;
|
|
10
|
+
dispatch: (event: SkillEvent) => Promise<{
|
|
11
|
+
handled: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
hasHandlers: () => boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare const createEventHandlerRegistry: () => EventHandlerRegistry;
|
|
16
|
+
//# sourceMappingURL=event-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-handler.d.ts","sourceRoot":"","sources":["../src/event-handler.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;AAEtE,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,KAAK,IAAI,CAAA;IACtD,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;IAC9D,WAAW,EAAE,MAAM,OAAO,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,0BAA0B,QAAO,oBAgC7C,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const createEventHandlerRegistry = () => {
|
|
2
|
+
const handlers = new Map();
|
|
3
|
+
return {
|
|
4
|
+
on: (eventName, handler) => {
|
|
5
|
+
const existing = handlers.get(eventName) ?? [];
|
|
6
|
+
handlers.set(eventName, [...existing, handler]);
|
|
7
|
+
},
|
|
8
|
+
dispatch: async (event) => {
|
|
9
|
+
const specific = handlers.get(event.eventType) ?? [];
|
|
10
|
+
const wildcard = handlers.get('*') ?? [];
|
|
11
|
+
const all = [...specific, ...wildcard];
|
|
12
|
+
if (all.length === 0)
|
|
13
|
+
return { handled: false };
|
|
14
|
+
for (const handler of all) {
|
|
15
|
+
try {
|
|
16
|
+
await handler(event);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
console.error(`[Events] Handler for '${event.eventType}' failed:`, error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return { handled: true };
|
|
23
|
+
},
|
|
24
|
+
hasHandlers: () => handlers.size > 0
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=event-handler.js.map
|
|
@@ -0,0 +1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A;AACH,CAAC,CAAA"}
|
package/dist/http-server.d.ts
CHANGED
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* Skill authors never interact with it directly — they register tool handlers
|
|
18
18
|
* and ingress handlers through the SDK, and this server routes to them.
|
|
19
19
|
*
|
|
20
|
-
* See docs/technical
|
|
21
|
-
* See docs/technical
|
|
20
|
+
* See docs/technical/architecture/skills/architecture.md §4.1.
|
|
21
|
+
* See docs/technical/architecture/skills/sandbox-runtime.md §2-3.
|
|
22
22
|
*/
|
|
23
23
|
import * as http from 'node:http';
|
|
24
24
|
export type RouteHandler = (req: ParsedRequest) => Promise<{
|
package/dist/http-server.js
CHANGED
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* Skill authors never interact with it directly — they register tool handlers
|
|
18
18
|
* and ingress handlers through the SDK, and this server routes to them.
|
|
19
19
|
*
|
|
20
|
-
* See docs/technical
|
|
21
|
-
* See docs/technical
|
|
20
|
+
* See docs/technical/architecture/skills/architecture.md §4.1.
|
|
21
|
+
* See docs/technical/architecture/skills/sandbox-runtime.md §2-3.
|
|
22
22
|
*/
|
|
23
23
|
import * as http from 'node:http';
|
|
24
24
|
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
package/dist/index.d.ts
CHANGED
|
@@ -5,18 +5,37 @@
|
|
|
5
5
|
* Communication is HTTP-native: outbound REST calls to the Mission API,
|
|
6
6
|
* inbound HTTP requests via Daytona Preview URLs.
|
|
7
7
|
*
|
|
8
|
-
* See docs/technical
|
|
9
|
-
* See docs/technical
|
|
8
|
+
* See docs/technical/architecture/skills/architecture.md.
|
|
9
|
+
* See docs/technical/architecture/skills/sandbox-runtime.md.
|
|
10
10
|
*/
|
|
11
11
|
export type { Tool, ToolFunction, ToolFunctionPermission, ToolKind } from '@mission/models';
|
|
12
12
|
export type { ApiClient } from './api';
|
|
13
13
|
export type { AuthCredentials, AuthModule, OAuthCredentials } from './auth';
|
|
14
14
|
export type { ConfigModule } from './config';
|
|
15
15
|
export type { SkillContext } from './context';
|
|
16
|
-
export type {
|
|
16
|
+
export type { EventHandler, EventHandlerRegistry, SkillEvent } from './event-handler';
|
|
17
17
|
export type { IngressHandler, IngressModule, IngressRequest, IngressResponse, IngressStreamEvents, IngressUrl } from './ingress';
|
|
18
18
|
export type { LogModule } from './logging';
|
|
19
|
-
export type { MissionSDK, MissionSDKOptions } from './sdk';
|
|
19
|
+
export type { AgentMessage, MissionSDK, MissionSDKOptions } from './sdk';
|
|
20
20
|
export { createMissionSDK } from './sdk';
|
|
21
|
-
export type { ToolHandler, ToolsModule } from './tool-registry';
|
|
21
|
+
export type { ToolCallContext, ToolCallEnvelope, ToolCallInput, ToolHandler, ToolsModule } from './tool-registry';
|
|
22
|
+
/** Incoming webhook request passed to a skill's `webhook()` handler. */
|
|
23
|
+
export type WebhookRequest = {
|
|
24
|
+
body: unknown;
|
|
25
|
+
headers: Record<string, string>;
|
|
26
|
+
};
|
|
27
|
+
/** Optional response a `webhook()` handler can return to the external service. */
|
|
28
|
+
export type WebhookResponse = {
|
|
29
|
+
status: number;
|
|
30
|
+
body: unknown;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Result of a skill's `webhook()` handler.
|
|
34
|
+
* - `externalId`: tenant identifier used to route the event to the correct connection(s).
|
|
35
|
+
* - `response`: optional custom HTTP response to send back to the caller.
|
|
36
|
+
*/
|
|
37
|
+
export type WebhookResult = {
|
|
38
|
+
externalId: string | null;
|
|
39
|
+
response?: WebhookResponse;
|
|
40
|
+
};
|
|
22
41
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,YAAY,EACV,IAAI,EACJ,YAAY,EACZ,sBAAsB,EACtB,QAAQ,EACT,MAAM,iBAAiB,CAAA;AACxB,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,C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GAAG;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,OAAO,CAAA;CACd,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,QAAQ,CAAC,EAAE,eAAe,CAAA;CAC3B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* Communication is HTTP-native: outbound REST calls to the Mission API,
|
|
6
6
|
* inbound HTTP requests via Daytona Preview URLs.
|
|
7
7
|
*
|
|
8
|
-
* See docs/technical
|
|
9
|
-
* See docs/technical
|
|
8
|
+
* See docs/technical/architecture/skills/architecture.md.
|
|
9
|
+
* See docs/technical/architecture/skills/sandbox-runtime.md.
|
|
10
10
|
*/
|
|
11
11
|
export { createMissionSDK } from './sdk.js';
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA2BH,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA"}
|
package/dist/ingress.d.ts
CHANGED
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
* There is no need to pre-declare them in mission.json — the SDK registers
|
|
27
27
|
* them dynamically and reports them to the control plane at ready().
|
|
28
28
|
*
|
|
29
|
-
* See docs/technical
|
|
30
|
-
* See docs/technical
|
|
29
|
+
* See docs/technical/architecture/skills/architecture.md §4.4.
|
|
30
|
+
* See docs/technical/architecture/skills/sandbox-runtime.md §2-3.
|
|
31
31
|
*/
|
|
32
32
|
import type { ApiClient } from './api';
|
|
33
33
|
export type IngressRequest = {
|
package/dist/ingress.js
CHANGED
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
* There is no need to pre-declare them in mission.json — the SDK registers
|
|
27
27
|
* them dynamically and reports them to the control plane at ready().
|
|
28
28
|
*
|
|
29
|
-
* See docs/technical
|
|
30
|
-
* See docs/technical
|
|
29
|
+
* See docs/technical/architecture/skills/architecture.md §4.4.
|
|
30
|
+
* See docs/technical/architecture/skills/sandbox-runtime.md §2-3.
|
|
31
31
|
*/
|
|
32
32
|
// ─── Factory ─────────────────────────────────────────────────────────────────
|
|
33
33
|
export function createIngressRegistry(api) {
|
package/dist/logging.d.ts
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* Transport: skill.ingestLogs tRPC mutation (batched, fire-and-forget).
|
|
19
19
|
*/
|
|
20
20
|
import type { ApiClient } from './api';
|
|
21
|
+
import type { AuthFailureTracker } from './auth-failure-tracker';
|
|
21
22
|
type LogLevel = 'log' | 'error' | 'warn' | 'info' | 'debug';
|
|
22
23
|
export type LogEntry = {
|
|
23
24
|
level: LogLevel;
|
|
@@ -42,7 +43,7 @@ export type LogModule = {
|
|
|
42
43
|
* After this call, all console.log/error/warn/info/debug calls will
|
|
43
44
|
* be intercepted, enriched with metadata, and batched for shipping.
|
|
44
45
|
*/
|
|
45
|
-
export declare function installLogging(api: ApiClient): void;
|
|
46
|
+
export declare function installLogging(api: ApiClient, tracker?: AuthFailureTracker): void;
|
|
46
47
|
/**
|
|
47
48
|
* Create a structured log module.
|
|
48
49
|
*
|
package/dist/logging.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,E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transport: skill.ingestLogs tRPC mutation (batched, fire-and-forget).
|
|
19
19
|
*/
|
|
20
|
+
import { TRPCClientError } from '@trpc/client';
|
|
20
21
|
// ─── Constants ───────────────────────────────────────────────────────────────
|
|
21
22
|
/** How often to flush the log buffer (ms). */
|
|
22
23
|
const FLUSH_INTERVAL_MS = 5_000;
|
|
@@ -26,6 +27,7 @@ const FLUSH_THRESHOLD = 50;
|
|
|
26
27
|
let buffer = [];
|
|
27
28
|
let flushTimer = null;
|
|
28
29
|
let apiRef = null;
|
|
30
|
+
let trackerRef = null;
|
|
29
31
|
let originalConsole = null;
|
|
30
32
|
function getOriginal() {
|
|
31
33
|
// Return saved originals if we've installed console override,
|
|
@@ -51,9 +53,14 @@ async function flush() {
|
|
|
51
53
|
buffer = [];
|
|
52
54
|
try {
|
|
53
55
|
await apiRef.trpc.skill.ingestLogs.mutate({ entries });
|
|
56
|
+
trackerRef?.recordSuccess();
|
|
54
57
|
}
|
|
55
58
|
catch (err) {
|
|
56
59
|
getOriginal().error('[Logging] Flush failed:', err);
|
|
60
|
+
if (err instanceof TRPCClientError && err.data?.code === 'UNAUTHORIZED') {
|
|
61
|
+
trackerRef?.recordFailure();
|
|
62
|
+
return; // Don't re-enqueue — they'd fail again with the same error
|
|
63
|
+
}
|
|
57
64
|
// Re-enqueue failed entries (drop if buffer is huge to avoid OOM)
|
|
58
65
|
if (buffer.length < 500) {
|
|
59
66
|
buffer.unshift(...entries);
|
|
@@ -68,8 +75,9 @@ async function flush() {
|
|
|
68
75
|
* After this call, all console.log/error/warn/info/debug calls will
|
|
69
76
|
* be intercepted, enriched with metadata, and batched for shipping.
|
|
70
77
|
*/
|
|
71
|
-
export function installLogging(api) {
|
|
78
|
+
export function installLogging(api, tracker) {
|
|
72
79
|
apiRef = api;
|
|
80
|
+
trackerRef = tracker ?? null;
|
|
73
81
|
// Preserve original console methods
|
|
74
82
|
originalConsole = {
|
|
75
83
|
log: console.log.bind(console),
|
package/dist/logging.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AA8B9C,gFAAgF;AAEhF,8CAA8C;AAC9C,MAAM,iBAAiB,GAAG,KAAK,CAAA;AAE/B,oDAAoD;AACpD,MAAM,eAAe,GAAG,EAAE,CAAA;AAE1B,gFAAgF;AAEhF,IAAI,MAAM,GAAe,EAAE,CAAA;AAC3B,IAAI,UAAU,GAA0C,IAAI,CAAA;AAC5D,IAAI,MAAM,GAAqB,IAAI,CAAA;AACnC,IAAI,UAAU,GAA8B,IAAI,CAAA;AAChD,IAAI,eAAe,GAA2B,IAAI,CAAA;AAElD,SAAS,WAAW;IAClB,8DAA8D;IAC9D,sDAAsD;IACtD,OAAO,CACL,eAAe,IAAI;QACjB,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;QAC9B,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;QAClC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QAChC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QAChC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;KACnC,CACF,CAAA;AACH,CAAC;AAED,SAAS,OAAO,CAAC,KAAe;IAC9B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClB,IAAI,MAAM,CAAC,MAAM,IAAI,eAAe,EAAE,CAAC;QACrC,KAAK,KAAK,EAAE,CAAA;IACd,CAAC;AACH,CAAC;AAED,KAA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k.d.ts
CHANGED
|
@@ -14,19 +14,20 @@
|
|
|
14
14
|
* Lifecycle:
|
|
15
15
|
* 1. const mission = createMissionSDK() — create SDK (no connection yet)
|
|
16
16
|
* 2. await mission.connect() — start HTTP server, install logging
|
|
17
|
-
* 3. // auth, config
|
|
17
|
+
* 3. // auth, config are now usable
|
|
18
18
|
* 4. mission.tools.registerAll(handlers) — register tool handlers
|
|
19
19
|
* 5. mission.ingress.on('name', handler) — register ingress handlers
|
|
20
|
-
* 6. mission.
|
|
21
|
-
* 7.
|
|
20
|
+
* 6. mission.on('event_type', handler) — register event handler
|
|
21
|
+
* 7. mission.onShutdown(() => cleanup()) — register shutdown hooks
|
|
22
|
+
* 8. await mission.ready() — signal readiness, accept traffic
|
|
22
23
|
*
|
|
23
|
-
* See docs/technical
|
|
24
|
-
* See docs/technical
|
|
24
|
+
* See docs/technical/architecture/skills/architecture.md §4 and §6.
|
|
25
|
+
* See docs/technical/architecture/skills/sandbox-runtime.md.
|
|
25
26
|
*/
|
|
26
27
|
import { type AuthModule } from './auth';
|
|
27
28
|
import { type ConfigModule } from './config';
|
|
28
29
|
import { type SkillContext } from './context';
|
|
29
|
-
import { type
|
|
30
|
+
import { type EventHandler } from './event-handler';
|
|
30
31
|
import { type IngressModule } from './ingress';
|
|
31
32
|
import { type LogModule } from './logging';
|
|
32
33
|
import { type ToolsModule } from './tool-registry';
|
|
@@ -43,6 +44,31 @@ export type MissionSDKOptions = {
|
|
|
43
44
|
*/
|
|
44
45
|
port?: number;
|
|
45
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* A message from a skill to the agent.
|
|
49
|
+
*
|
|
50
|
+
* Skills process their domain-specific inbound data and produce
|
|
51
|
+
* human-readable messages that agents can reason about.
|
|
52
|
+
*/
|
|
53
|
+
export type AgentMessage = {
|
|
54
|
+
/**
|
|
55
|
+
* Human-readable message describing what happened.
|
|
56
|
+
* This is what the agent sees and reasons about.
|
|
57
|
+
*/
|
|
58
|
+
message: string;
|
|
59
|
+
/**
|
|
60
|
+
* Structured context data the agent can reference.
|
|
61
|
+
* Include IDs, metadata, and any data that helps the agent
|
|
62
|
+
* take follow-up actions using the skill's tools.
|
|
63
|
+
*/
|
|
64
|
+
context?: Record<string, unknown>;
|
|
65
|
+
/**
|
|
66
|
+
* Optional deduplication key to prevent duplicate processing.
|
|
67
|
+
* If the platform has already processed a message with this key,
|
|
68
|
+
* it will be silently dropped.
|
|
69
|
+
*/
|
|
70
|
+
deduplicationKey?: string;
|
|
71
|
+
};
|
|
46
72
|
export type MissionSDK = {
|
|
47
73
|
/** The resolved skill context. */
|
|
48
74
|
context: SkillContext;
|
|
@@ -50,14 +76,41 @@ export type MissionSDK = {
|
|
|
50
76
|
auth: AuthModule;
|
|
51
77
|
/** Fetch per-installation configuration. */
|
|
52
78
|
config: ConfigModule;
|
|
53
|
-
/** Send messages to the agent about external events. */
|
|
54
|
-
events: EventsModule;
|
|
55
79
|
/** Register ingress handlers and discover public URLs. */
|
|
56
80
|
ingress: IngressModule;
|
|
57
81
|
/** Structured logger — logs are batched and shipped to the Mission platform. */
|
|
58
82
|
log: LogModule;
|
|
59
83
|
/** Register tool handlers that the platform can invoke. */
|
|
60
84
|
tools: ToolsModule;
|
|
85
|
+
/**
|
|
86
|
+
* Subscribe to typed events delivered by the platform.
|
|
87
|
+
* Use '*' to subscribe to all event types.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* mission.on('mailbox_activity', async (event) => {
|
|
92
|
+
* await mission.emit({ message: '...', context: event.payload })
|
|
93
|
+
* })
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
on: (eventName: string, handler: EventHandler) => void;
|
|
97
|
+
/**
|
|
98
|
+
* Send a message to the agent about an external event.
|
|
99
|
+
* The platform routes it to the appropriate agent(s) based on
|
|
100
|
+
* the workspace's routing configuration.
|
|
101
|
+
*
|
|
102
|
+
* Sends an agent message to the platform for processing.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* await mission.emit({
|
|
107
|
+
* message: 'New email from john@example.com',
|
|
108
|
+
* context: { emailAddress: 'john@example.com' },
|
|
109
|
+
* deduplicationKey: 'gmail-push-12345'
|
|
110
|
+
* })
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
emit: (message: AgentMessage) => Promise<void>;
|
|
61
114
|
/**
|
|
62
115
|
* Connect to the Mission platform.
|
|
63
116
|
*
|
|
@@ -65,14 +118,14 @@ export type MissionSDK = {
|
|
|
65
118
|
* ingress traffic), installs the console override for structured
|
|
66
119
|
* logging, and begins the keep-alive heartbeat loop.
|
|
67
120
|
*
|
|
68
|
-
* After this call, `auth`, `config`, `
|
|
121
|
+
* After this call, `auth`, `config`, `emit`, and `ingress.getPublicUrl`
|
|
69
122
|
* are usable.
|
|
70
123
|
*/
|
|
71
124
|
connect: () => Promise<void>;
|
|
72
125
|
/**
|
|
73
126
|
* Signal readiness and start accepting tool calls and ingress traffic.
|
|
74
127
|
*
|
|
75
|
-
* Call this AFTER registering all tools and
|
|
128
|
+
* Call this AFTER registering all tools, ingress handlers, and event handlers.
|
|
76
129
|
* The returned promise resolves when the process receives a shutdown
|
|
77
130
|
* signal (SIGTERM/SIGINT) and graceful shutdown completes.
|
|
78
131
|
*/
|
|
@@ -94,6 +147,28 @@ export type MissionSDK = {
|
|
|
94
147
|
* ```
|
|
95
148
|
*/
|
|
96
149
|
onShutdown: (handler: () => Promise<void> | void) => void;
|
|
150
|
+
/**
|
|
151
|
+
* Register a health check handler for install-time smoke testing.
|
|
152
|
+
*
|
|
153
|
+
* The handler is called by the platform after the skill process starts
|
|
154
|
+
* during installation. It should verify that the skill can reach its
|
|
155
|
+
* external dependencies (e.g., API keys work, OAuth tokens are valid).
|
|
156
|
+
*
|
|
157
|
+
* This is NOT a tool — it is never exposed to the LLM or listed in
|
|
158
|
+
* reported tools. It is served on an internal HTTP endpoint
|
|
159
|
+
* (`POST /_mission/health-check`) that only the platform calls.
|
|
160
|
+
*
|
|
161
|
+
* If no handler is registered, the health check is skipped (not failed).
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* mission.onHealthCheck(async () => {
|
|
166
|
+
* await gmail.listLabels()
|
|
167
|
+
* return { ok: true }
|
|
168
|
+
* })
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
onHealthCheck: (handler: () => Promise<unknown> | unknown) => void;
|
|
97
172
|
};
|
|
98
173
|
/**
|
|
99
174
|
* Create a Mission SDK instance.
|
|
@@ -110,6 +185,9 @@ export type MissionSDK = {
|
|
|
110
185
|
*
|
|
111
186
|
* mission.tools.registerAll(handlers)
|
|
112
187
|
* mission.ingress.on('webhook', handler)
|
|
188
|
+
* mission.on('mailbox_activity', async (event) => {
|
|
189
|
+
* await mission.emit({ message: '...', context: event.payload })
|
|
190
|
+
* })
|
|
113
191
|
* mission.onShutdown(() => cleanup())
|
|
114
192
|
*
|
|
115
193
|
* await mission.ready()
|
package/dist/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,OAAO,EAAE,KAAK,UAAU,EAAoB,MAAM,QAAQ,CAAA;AAE1D,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,UAAU,CAAA;AAChE,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,WAAW,CAAA;AACjE,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE/E,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,WAAW,CAAA;AAClB,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,WAAW,CAAA;AAClB,OAA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