@stigmer/sdk 2.0.0 → 3.0.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.
- package/README.md +55 -0
- package/__tests__/runner-adapter.test.d.ts +2 -0
- package/__tests__/runner-adapter.test.d.ts.map +1 -0
- package/__tests__/runner-adapter.test.js +88 -0
- package/__tests__/runner-adapter.test.js.map +1 -0
- package/execution/__tests__/tool-view.fixtures.test.d.ts +2 -0
- package/execution/__tests__/tool-view.fixtures.test.d.ts.map +1 -0
- package/execution/__tests__/tool-view.fixtures.test.js +102 -0
- package/execution/__tests__/tool-view.fixtures.test.js.map +1 -0
- package/execution/tool-view.d.ts +88 -0
- package/execution/tool-view.d.ts.map +1 -0
- package/execution/tool-view.js +300 -0
- package/execution/tool-view.js.map +1 -0
- package/gen/session.d.ts +1 -2
- package/gen/session.d.ts.map +1 -1
- package/gen/session.js +0 -8
- package/gen/session.js.map +1 -1
- package/index.d.ts +2 -1
- package/index.d.ts.map +1 -1
- package/index.js +4 -0
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/runner-adapter.d.ts +44 -4
- package/runner-adapter.d.ts.map +1 -1
- package/runner-adapter.js +29 -1
- package/runner-adapter.js.map +1 -1
- package/src/__tests__/runner-adapter.test.ts +122 -0
- package/src/execution/__tests__/tool-view.fixtures.test.ts +144 -0
- package/src/execution/tool-view.ts +418 -0
- package/src/gen/session.ts +1 -7
- package/src/index.ts +16 -1
- package/src/runner-adapter.ts +70 -4
package/src/gen/session.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { ToolApprovalOverrideSchema, McpServerUsageSchema } from "@stigmer/proto
|
|
|
9
9
|
import { SessionSchema, type Session } from "@stigmer/protos/ai/stigmer/agentic/session/v1/api_pb";
|
|
10
10
|
import { SessionCommandController } from "@stigmer/protos/ai/stigmer/agentic/session/v1/command_pb";
|
|
11
11
|
import { Harness, CursorMode, ExecutionTarget, GitWriteBackMode } from "@stigmer/protos/ai/stigmer/agentic/session/v1/enum_pb";
|
|
12
|
-
import { SessionIdSchema, UpdateSessionSubjectRequestSchema,
|
|
12
|
+
import { SessionIdSchema, UpdateSessionSubjectRequestSchema, ListSessionsRequestSchema, SessionListSchema, ListSessionsByAgentRequestSchema, type UpdateSessionSubjectRequest, type ListSessionsRequest, type SessionList, type ListSessionsByAgentRequest } from "@stigmer/protos/ai/stigmer/agentic/session/v1/io_pb";
|
|
13
13
|
import { SessionQueryController } from "@stigmer/protos/ai/stigmer/agentic/session/v1/query_pb";
|
|
14
14
|
import { SessionSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/spec_pb";
|
|
15
15
|
import { GitRepoSourceSchema, LocalPathSourceSchema, WorkspaceSourceSchema, WorkspaceEntrySchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/workspace_pb";
|
|
@@ -51,12 +51,6 @@ export class SessionClient {
|
|
|
51
51
|
} catch (e) { throw wrapError(e); }
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
async updateSessionMemory(input: UpdateSessionMemoryRequest): Promise<Session> {
|
|
55
|
-
try {
|
|
56
|
-
return await this.command.updateSessionMemory(input);
|
|
57
|
-
} catch (e) { throw wrapError(e); }
|
|
58
|
-
}
|
|
59
|
-
|
|
60
54
|
async delete(id: string): Promise<Session> {
|
|
61
55
|
try {
|
|
62
56
|
return await this.command.delete(create(SessionIdSchema, { value: id }));
|
package/src/index.ts
CHANGED
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
export { Stigmer } from "./stigmer";
|
|
5
5
|
|
|
6
6
|
// Runner adapter
|
|
7
|
-
export {
|
|
7
|
+
export {
|
|
8
|
+
type RunnerAdapter,
|
|
9
|
+
type RunnerWorkerHost,
|
|
10
|
+
createRunnerAdapter,
|
|
11
|
+
} from "./runner-adapter";
|
|
8
12
|
|
|
9
13
|
// Configuration
|
|
10
14
|
export { type StigmerConfig, type TokenProvider } from "./config";
|
|
@@ -177,6 +181,17 @@ export {
|
|
|
177
181
|
|
|
178
182
|
// Session utilities (hand-written)
|
|
179
183
|
export { PENDING_SUBJECT, resolvedSubject } from "./session";
|
|
184
|
+
|
|
185
|
+
// Tool-call view model (framework-agnostic; shared by @stigmer/react and @stigmer/ink)
|
|
186
|
+
export {
|
|
187
|
+
ToolKind,
|
|
188
|
+
resolveToolKind,
|
|
189
|
+
resolveToolKindByName,
|
|
190
|
+
normalizeToolResult,
|
|
191
|
+
type ToolResultView,
|
|
192
|
+
type ToolSearchMatch,
|
|
193
|
+
type ToolContentBlock,
|
|
194
|
+
} from "./execution/tool-view";
|
|
180
195
|
export { SkillClient, type SkillInput } from "./gen/skill";
|
|
181
196
|
export {
|
|
182
197
|
WorkflowClient,
|
package/src/runner-adapter.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// The framework-agnostic RunnerAdapter contract plus the createRunnerAdapter
|
|
2
|
+
// construction helper. Canonical home for both; @stigmer/react re-exports them.
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Framework-agnostic RunnerAdapter interface.
|
|
3
6
|
*
|
|
@@ -8,14 +11,77 @@
|
|
|
8
11
|
* When `executionTarget` is `"local"`, SDK clients automatically call
|
|
9
12
|
* the adapter at the appropriate lifecycle points. The consumer never
|
|
10
13
|
* needs to manage runner processes directly.
|
|
14
|
+
*
|
|
15
|
+
* Sessions and workflow executions have different lifecycles. A session
|
|
16
|
+
* is a long-lived, multi-turn conversation with no terminal phase, so its
|
|
17
|
+
* worker is tied to whether the session is open (in use): `onSessionOpened`
|
|
18
|
+
* when the session is opened, `onSessionClosed` when it is closed. A
|
|
19
|
+
* workflow execution runs to a terminal phase, so its worker is tied to
|
|
20
|
+
* creation and completion.
|
|
11
21
|
*/
|
|
12
22
|
export interface RunnerAdapter {
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Called when a local session is opened (engaged). The adapter should
|
|
25
|
+
* ensure a runner worker is polling the session's task queue. Idempotent:
|
|
26
|
+
* may be called again for an already-open session (e.g. on re-open).
|
|
27
|
+
*/
|
|
28
|
+
onSessionOpened(sessionId: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Called when a local session is closed (no longer in use). The adapter
|
|
31
|
+
* should tear down the session's runner worker.
|
|
32
|
+
*/
|
|
33
|
+
onSessionClosed(sessionId: string): Promise<void>;
|
|
17
34
|
/** Called after a workflow execution is created with executionTarget=LOCAL. */
|
|
18
35
|
onWorkflowExecutionCreated(executionId: string): Promise<void>;
|
|
19
36
|
/** Called when a workflow execution reaches a terminal phase. */
|
|
20
37
|
onWorkflowExecutionTerminated(executionId: string): Promise<void>;
|
|
21
38
|
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A runner backend that can start and stop per-session and per-execution
|
|
42
|
+
* workers. This is the worker-lifecycle slice of a runner host — the only
|
|
43
|
+
* capability `createRunnerAdapter` needs — not the full process surface
|
|
44
|
+
* (start/status/token/shutdown).
|
|
45
|
+
*
|
|
46
|
+
* Several backends already satisfy this shape structurally: the in-process
|
|
47
|
+
* `StigmerRunnerManager` (`@stigmer/runner`), the desktop's embedded-runner
|
|
48
|
+
* context (Tauri IPC), and any custom runner-management API. Pass one to
|
|
49
|
+
* `createRunnerAdapter` to get a wired {@link RunnerAdapter}.
|
|
50
|
+
*/
|
|
51
|
+
export interface RunnerWorkerHost {
|
|
52
|
+
// Return Promise<unknown>, not Promise<void>: a Promise<string> (e.g. the
|
|
53
|
+
// desktop returns the worker's task queue) is not assignable to Promise<void>,
|
|
54
|
+
// so void would reject real hosts. The factory awaits and discards the value.
|
|
55
|
+
addSession(sessionId: string): Promise<unknown>;
|
|
56
|
+
removeSession(sessionId: string): Promise<unknown>;
|
|
57
|
+
addWorkflowExecution(executionId: string): Promise<unknown>;
|
|
58
|
+
removeWorkflowExecution(executionId: string): Promise<unknown>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Build a {@link RunnerAdapter} that delegates to a {@link RunnerWorkerHost},
|
|
63
|
+
* collapsing the per-embedder boilerplate of wiring lifecycle events to worker
|
|
64
|
+
* management into a single call.
|
|
65
|
+
*
|
|
66
|
+
* The adapter does not add its own state: idempotency and deduplication are the
|
|
67
|
+
* host's responsibility (the SDK calls `onSessionOpened` on every open).
|
|
68
|
+
*/
|
|
69
|
+
export function createRunnerAdapter(host: RunnerWorkerHost): RunnerAdapter {
|
|
70
|
+
// The mapping is deliberate and asymmetric: sessions attach/detach on
|
|
71
|
+
// open/close, workflow executions on create/terminate. Keep it here so no
|
|
72
|
+
// embedder re-derives (and mis-wires) it.
|
|
73
|
+
return {
|
|
74
|
+
onSessionOpened: async (sessionId) => {
|
|
75
|
+
await host.addSession(sessionId);
|
|
76
|
+
},
|
|
77
|
+
onSessionClosed: async (sessionId) => {
|
|
78
|
+
await host.removeSession(sessionId);
|
|
79
|
+
},
|
|
80
|
+
onWorkflowExecutionCreated: async (executionId) => {
|
|
81
|
+
await host.addWorkflowExecution(executionId);
|
|
82
|
+
},
|
|
83
|
+
onWorkflowExecutionTerminated: async (executionId) => {
|
|
84
|
+
await host.removeWorkflowExecution(executionId);
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|