@assistant-wi/core 0.0.1-alpha.7

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 ADDED
@@ -0,0 +1,40 @@
1
+ # @assistant-wi/core
2
+
3
+ `@assistant-wi/core` is the foundational contract package for assistant-wi.
4
+
5
+ ## Role
6
+
7
+ This package owns the extracted, framework-neutral contract layer that sits below
8
+ runtime transports and interaction orchestration.
9
+
10
+ ## Owns
11
+
12
+ - runtime model contracts
13
+ - tool authoring contracts and `createTool`
14
+ - plain message DTOs and presentation part types
15
+
16
+ ## Does not own
17
+
18
+ - HTTP or gRPC transport details
19
+ - parser or validation behavior
20
+ - interaction state or framework bindings
21
+ - storage, replay, queueing, or persistence strategy
22
+
23
+ ## Dependency direction
24
+
25
+ Higher-level packages can depend on `@assistant-wi/core`, while `@assistant-wi/core`
26
+ stays free of transport, UI, and orchestration concerns.
27
+
28
+ ## Runtime API relation
29
+
30
+ `@assistant-wi/runtime` remains the transport-facing compatibility package for wire,
31
+ codec, and protocol surfaces while re-exporting the core-owned runtime model layer.
32
+
33
+ ## Tool execution relation
34
+
35
+ `@assistant-wi/interaction` can keep normalization and parser behavior while reusing
36
+ the core-owned tool and message contracts.
37
+
38
+ ## Status
39
+
40
+ Current foundational owner.
@@ -0,0 +1,7 @@
1
+ import { MessageKnownPart, MessagePartUnknown } from './part';
2
+ import { MessageStatus } from './status';
3
+ export type { MessagePartFile as RuntimeAssistantFilePart, MessagePartReasoning as RuntimeAssistantReasoningPart, MessageProviderMetadata as RuntimeAssistantProviderMetadata, MessagePartSourceDocument as RuntimeAssistantSourceDocumentPart, MessagePartSourceUrl as RuntimeAssistantSourceUrlPart, MessagePartText as RuntimeAssistantTextPart, MessageToolApproval as RuntimeAssistantToolApproval, MessagePartTool as RuntimeAssistantToolPart, MessagePartUnknown as RuntimeAssistantUnknownPart, } from './part';
4
+ export type RuntimeAssistantToolPartState = 'streaming' | 'call' | 'done' | 'error' | 'canceled';
5
+ export type RuntimeAssistantPart = MessageKnownPart | MessagePartUnknown;
6
+ export declare function collectPendingToolCallIdsFromAssistantParts(parts: ReadonlyArray<RuntimeAssistantPart>): string[];
7
+ export declare function toDefaultStatusFromAssistantParts(parts: ReadonlyArray<RuntimeAssistantPart>): MessageStatus;
@@ -0,0 +1,127 @@
1
+ import { RuntimeMessageStatus } from './messages';
2
+ export type RuntimeTelemetryEvent = {
3
+ type: 'chat.rendered.v1' | 'chat.focus_changed.v1' | 'chat.session_selected.v1' | 'chat.prompt_edit_started.v1' | 'chat.prompt_submitted.v1' | 'chat.response_started.v1' | 'chat.response_finished.v1' | 'chat.response_stopped.v1' | 'chat.feedback_set.v1' | 'chat.tool_call_started.v1' | 'chat.tool_call_finished.v1';
4
+ occurredAt: Date;
5
+ sessionId?: string | undefined;
6
+ messageId?: string | undefined;
7
+ payload: Record<string, unknown>;
8
+ };
9
+ export type RuntimeMessageStreamFinishReason = 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other';
10
+ export type RuntimeEvent = {
11
+ v: 1;
12
+ type: 'message.created';
13
+ messageId: string;
14
+ sessionId: string;
15
+ role: 'assistant';
16
+ status: RuntimeMessageStatus;
17
+ } | {
18
+ v: 1;
19
+ type: 'message.checkpoint.created';
20
+ messageId: string;
21
+ checkpointId: string;
22
+ } | {
23
+ v: 1;
24
+ type: 'message.revision.rebased';
25
+ messageId: string;
26
+ checkpointId: string;
27
+ revisionId: string;
28
+ } | {
29
+ v: 1;
30
+ type: 'part.text.start';
31
+ partId: string;
32
+ } | {
33
+ v: 1;
34
+ type: 'part.text.delta';
35
+ partId: string;
36
+ delta: string;
37
+ } | {
38
+ v: 1;
39
+ type: 'part.text.end';
40
+ partId: string;
41
+ } | {
42
+ v: 1;
43
+ type: 'part.reasoning.start';
44
+ partId: string;
45
+ } | {
46
+ v: 1;
47
+ type: 'part.reasoning.delta';
48
+ partId: string;
49
+ delta: string;
50
+ } | {
51
+ v: 1;
52
+ type: 'part.reasoning.end';
53
+ partId: string;
54
+ } | {
55
+ v: 1;
56
+ type: 'part.source-url';
57
+ sourceId: string;
58
+ url: string;
59
+ title?: string;
60
+ } | {
61
+ v: 1;
62
+ type: 'part.source-document';
63
+ sourceId: string;
64
+ mediaType: string;
65
+ title: string;
66
+ filename?: string;
67
+ } | {
68
+ v: 1;
69
+ type: 'part.file';
70
+ url: string;
71
+ mediaType: string;
72
+ filename?: string;
73
+ } | {
74
+ v: 1;
75
+ type: 'part.tool.input.start';
76
+ toolCallId: string;
77
+ name: string;
78
+ } | {
79
+ v: 1;
80
+ type: 'part.tool.input.delta';
81
+ toolCallId: string;
82
+ delta: string;
83
+ } | {
84
+ v: 1;
85
+ type: 'part.tool.call';
86
+ toolCallId: string;
87
+ name: string;
88
+ input: unknown;
89
+ } | {
90
+ v: 1;
91
+ type: 'part.tool.result';
92
+ toolCallId: string;
93
+ output: unknown;
94
+ preliminary?: boolean;
95
+ } | {
96
+ v: 1;
97
+ type: 'part.tool.error';
98
+ toolCallId: string;
99
+ error: string;
100
+ } | {
101
+ v: 1;
102
+ type: 'part.tool.denied';
103
+ toolCallId: string;
104
+ } | {
105
+ v: 1;
106
+ type: 'part.unknown';
107
+ rawType: string;
108
+ reason: 'unsupported_chunk' | 'invalid_chunk';
109
+ payload?: unknown;
110
+ } | {
111
+ v: 1;
112
+ type: 'message.status';
113
+ messageId: string;
114
+ status: RuntimeMessageStatus;
115
+ pendingToolCallIds?: string[];
116
+ };
117
+ export type RuntimeRunEvent = {
118
+ seq: number;
119
+ event: RuntimeEvent;
120
+ };
121
+ export type RuntimeRunEventStream = AsyncIterable<RuntimeRunEvent>;
122
+ export type RuntimeStreamRunEventsParams = {
123
+ responseId: string;
124
+ runId: string;
125
+ afterSeq: number;
126
+ signal?: AbortSignal;
127
+ };
@@ -0,0 +1,8 @@
1
+ export type MessageFeedbackType = 'like' | 'dislike';
2
+ export type MessageFeedback = {
3
+ sessionId: string;
4
+ messageId: string;
5
+ feedbackType: MessageFeedbackType;
6
+ reason: string | null;
7
+ updatedAt: Date;
8
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(t){const o=new Set;for(const e of t)e.type==="tool"&&(e.state==="done"||e.state==="error"||e.state==="canceled"||e.toolCallId.length>0&&o.add(e.toolCallId));return Array.from(o)}function r(t){return n(t).length>0?{version:1,code:"waiting_tool_outputs",reason:"system.awaiting_tool_outputs"}:{version:1,code:"completed",reason:"provider.stop"}}function s(t){return a(t),t}function a(t,o){if(typeof t.execute=="function")return;const e="createTool";throw new Error(`${e} now requires execute(); legacy workflow is no longer supported.`)}exports.collectPendingToolCallIdsFromAssistantParts=n;exports.createTool=s;exports.toDefaultStatusFromAssistantParts=r;
@@ -0,0 +1,15 @@
1
+ export * from './shared';
2
+ export * from './profile';
3
+ export * from './sessions';
4
+ export * from './tools';
5
+ export * from './assistant-parts';
6
+ export * from './messages';
7
+ export * from './events';
8
+ export * from './runtime-api';
9
+ export * from './tool';
10
+ export * from './part';
11
+ export * from './status';
12
+ export * from './feedback';
13
+ export * from './message';
14
+ export * from './message-data';
15
+ export * from './session';
@@ -0,0 +1,31 @@
1
+ function n(t) {
2
+ const o = /* @__PURE__ */ new Set();
3
+ for (const e of t)
4
+ e.type === "tool" && (e.state === "done" || e.state === "error" || e.state === "canceled" || e.toolCallId.length > 0 && o.add(e.toolCallId));
5
+ return Array.from(o);
6
+ }
7
+ function s(t) {
8
+ return n(t).length > 0 ? {
9
+ version: 1,
10
+ code: "waiting_tool_outputs",
11
+ reason: "system.awaiting_tool_outputs"
12
+ } : {
13
+ version: 1,
14
+ code: "completed",
15
+ reason: "provider.stop"
16
+ };
17
+ }
18
+ function a(t) {
19
+ return r(t), t;
20
+ }
21
+ function r(t, o) {
22
+ if (typeof t.execute == "function")
23
+ return;
24
+ const e = "createTool";
25
+ throw new Error(`${e} now requires execute(); legacy workflow is no longer supported.`);
26
+ }
27
+ export {
28
+ n as collectPendingToolCallIdsFromAssistantParts,
29
+ a as createTool,
30
+ s as toDefaultStatusFromAssistantParts
31
+ };
@@ -0,0 +1 @@
1
+ export type { Message as MessageData } from './message';
@@ -0,0 +1,16 @@
1
+ import { MessageFeedbackType } from './feedback';
2
+ import { MessagePart } from './part';
3
+ import { MessageStatus } from './status';
4
+ export type MessageRole = 'user' | 'assistant' | 'system';
5
+ export interface Message {
6
+ id: string;
7
+ role: MessageRole;
8
+ parts: MessagePart[];
9
+ createdAt: Date;
10
+ status?: MessageStatus | undefined;
11
+ policy?: unknown | undefined;
12
+ rebased?: boolean | undefined;
13
+ feedbackType?: MessageFeedbackType | null | undefined;
14
+ feedbackReason?: string | null | undefined;
15
+ feedbackUpdatedAt?: Date | null | undefined;
16
+ }
@@ -0,0 +1,46 @@
1
+ import { MessageFeedback } from './feedback';
2
+ import { Message } from './message';
3
+ import { MessagePart, MessagePartUnknown } from './part';
4
+ import { MessageStatus, MessageStatusCode, MessageStatusReason } from './status';
5
+ export type RuntimeMessage = Message;
6
+ export type RuntimeMessageFeedback = MessageFeedback;
7
+ export type RuntimeMessagePart = MessagePart;
8
+ export type RuntimeUnknownMessagePart = MessagePartUnknown;
9
+ export type RuntimeMessageStatus = MessageStatus;
10
+ export type RuntimeMessageStatusCode = MessageStatusCode;
11
+ export type RuntimeMessageStatusReason = MessageStatusReason;
12
+ export type RuntimeMessagePage = {
13
+ items: Message[];
14
+ nextCursor: string | null;
15
+ };
16
+ export type RuntimeMessageQueryDirection = 'after' | 'before';
17
+ export type RuntimeGetSessionMessagesParams = {
18
+ sessionId: string;
19
+ limit?: number;
20
+ cursor?: string;
21
+ direction?: RuntimeMessageQueryDirection;
22
+ };
23
+ export type RuntimeRespondUserMessagePart = {
24
+ type: string;
25
+ text?: string;
26
+ state?: string;
27
+ name?: string;
28
+ toolCallId?: string;
29
+ input?: unknown;
30
+ output?: unknown;
31
+ error?: string;
32
+ [key: string]: unknown;
33
+ };
34
+ export type RuntimeRespondUserMessage = {
35
+ id: string;
36
+ role: 'user';
37
+ parts: RuntimeRespondUserMessagePart[];
38
+ };
39
+ export type RuntimeSetMessageFeedbackParams = {
40
+ sessionId: string;
41
+ messageId: string;
42
+ feedbackType: 'like' | 'dislike';
43
+ reason?: string;
44
+ };
45
+ export type { RuntimeAssistantFilePart, RuntimeAssistantPart, RuntimeAssistantProviderMetadata, RuntimeAssistantReasoningPart, RuntimeAssistantSourceDocumentPart, RuntimeAssistantSourceUrlPart, RuntimeAssistantTextPart, RuntimeAssistantToolApproval, RuntimeAssistantToolPart, RuntimeAssistantToolPartState, RuntimeAssistantUnknownPart, } from './assistant-parts';
46
+ export { collectPendingToolCallIdsFromAssistantParts, toDefaultStatusFromAssistantParts, } from './assistant-parts';
package/dist/part.d.ts ADDED
@@ -0,0 +1,68 @@
1
+ export type MessageProviderMetadata = Record<string, unknown>;
2
+ export type MessageToolApproval = {
3
+ id: string;
4
+ approved?: boolean | undefined;
5
+ reason?: string | undefined;
6
+ };
7
+ export interface MessagePartReasoning {
8
+ type: 'reasoning';
9
+ text: string;
10
+ state: 'streaming' | 'done';
11
+ providerMetadata?: MessageProviderMetadata | undefined;
12
+ [key: string]: unknown;
13
+ }
14
+ export interface MessagePartText {
15
+ type: 'text';
16
+ text: string;
17
+ state: 'streaming' | 'done';
18
+ providerMetadata?: MessageProviderMetadata | undefined;
19
+ [key: string]: unknown;
20
+ }
21
+ export interface MessagePartTool {
22
+ type: 'tool';
23
+ name: string;
24
+ toolCallId: string;
25
+ input: unknown;
26
+ output?: unknown | undefined;
27
+ state: 'streaming' | 'call' | 'done' | 'error' | 'canceled';
28
+ error?: string | undefined;
29
+ providerExecuted?: boolean | undefined;
30
+ callProviderMetadata?: MessageProviderMetadata | undefined;
31
+ approval?: MessageToolApproval | undefined;
32
+ preliminary?: boolean | undefined;
33
+ title?: string | undefined;
34
+ [key: string]: unknown;
35
+ }
36
+ export interface MessagePartSourceUrl {
37
+ type: 'source-url';
38
+ sourceId: string;
39
+ url: string;
40
+ title?: string | undefined;
41
+ providerMetadata?: MessageProviderMetadata | undefined;
42
+ [key: string]: unknown;
43
+ }
44
+ export interface MessagePartSourceDocument {
45
+ type: 'source-document';
46
+ sourceId: string;
47
+ mediaType: string;
48
+ title: string;
49
+ filename?: string | undefined;
50
+ providerMetadata?: MessageProviderMetadata | undefined;
51
+ [key: string]: unknown;
52
+ }
53
+ export interface MessagePartFile {
54
+ type: 'file';
55
+ mediaType: string;
56
+ url: string;
57
+ filename?: string | undefined;
58
+ providerMetadata?: MessageProviderMetadata | undefined;
59
+ [key: string]: unknown;
60
+ }
61
+ export interface MessagePartUnknown {
62
+ type: 'unknown';
63
+ rawType?: string | undefined;
64
+ reason?: 'unsupported_chunk' | 'invalid_chunk' | undefined;
65
+ payload?: unknown | undefined;
66
+ }
67
+ export type MessagePart = MessageKnownPart | MessagePartUnknown;
68
+ export type MessageKnownPart = MessagePartText | MessagePartTool | MessagePartReasoning | MessagePartSourceUrl | MessagePartSourceDocument | MessagePartFile;
@@ -0,0 +1,42 @@
1
+ export type RuntimeConfiguration = {
2
+ profile: {
3
+ id: string;
4
+ name: string;
5
+ description: string | null;
6
+ };
7
+ agents: RuntimeAgent[];
8
+ models: Model[];
9
+ limits: RuntimeConfigurationLimits;
10
+ };
11
+ export type RuntimeAgent = {
12
+ id: string;
13
+ name: string;
14
+ };
15
+ export type Model = {
16
+ id: string;
17
+ name: string;
18
+ };
19
+ export type RuntimeConfigurationLimits = {
20
+ maxMessages: number | null;
21
+ maxTokens: number | null;
22
+ messagesPerMinute: number | null;
23
+ messagesPerHour: number | null;
24
+ messagesPerDay: number | null;
25
+ messagesPerWeek: number | null;
26
+ messagesPerMonth: number | null;
27
+ weightedTokensPerHour: number | null;
28
+ };
29
+ export type RuntimeLimitRemainingWindow = {
30
+ limit: number;
31
+ used: number;
32
+ remaining: number;
33
+ resetAt: Date | null;
34
+ };
35
+ export type RuntimeRemainingLimits = {
36
+ messagesPerMinute: RuntimeLimitRemainingWindow | null;
37
+ messagesPerHour: RuntimeLimitRemainingWindow | null;
38
+ messagesPerDay: RuntimeLimitRemainingWindow | null;
39
+ messagesPerWeek: RuntimeLimitRemainingWindow | null;
40
+ messagesPerMonth: RuntimeLimitRemainingWindow | null;
41
+ weightedTokensPerHour: RuntimeLimitRemainingWindow | null;
42
+ };
@@ -0,0 +1,88 @@
1
+ import { RuntimeRunEventStream, RuntimeStreamRunEventsParams, RuntimeTelemetryEvent } from './events';
2
+ import { MessageFeedback } from './feedback';
3
+ import { Session, SessionPage, SessionStar } from './session';
4
+ import { RuntimeGetSessionMessagesParams, RuntimeMessagePage, RuntimeRespondUserMessage, RuntimeSetMessageFeedbackParams } from './messages';
5
+ import { RuntimeConfiguration, RuntimeRemainingLimits } from './profile';
6
+ import { RuntimeCreateSessionParams, RuntimeGetSessionsParams } from './sessions';
7
+ import { RuntimeResult } from './shared';
8
+ import { RuntimeToolClaim, RuntimeToolClaimRequest, RuntimeToolClaimRenewParams, RuntimeToolOutputCommitRequest } from './tools';
9
+ export type RuntimeRunStatus = 'queued' | 'running' | 'waiting_tool_outputs' | 'ready_to_continue' | 'continued' | 'completed' | 'interrupted' | 'failed' | 'cancelled';
10
+ export type RuntimeCreateResponseParams = {
11
+ sessionId: string;
12
+ toolsKey: string;
13
+ agentId: string;
14
+ modelId: string;
15
+ idempotencyKey: string;
16
+ message: RuntimeRespondUserMessage;
17
+ context?: string;
18
+ tools?: Record<string, unknown>;
19
+ signal?: AbortSignal;
20
+ };
21
+ export type RuntimeCreateResponseResult = {
22
+ responseId: string;
23
+ sessionId: string;
24
+ userMessageId: string;
25
+ runId: string;
26
+ };
27
+ export type RuntimeContinueRunParams = {
28
+ responseId: string;
29
+ runId: string;
30
+ idempotencyKey: string;
31
+ signal?: AbortSignal;
32
+ };
33
+ export type RuntimeContinueRunResult = {
34
+ responseId: string;
35
+ runId: string;
36
+ status: Extract<RuntimeRunStatus, 'queued'>;
37
+ };
38
+ export type RuntimeGetSessionMessageRunParams = {
39
+ sessionId: string;
40
+ assistantMessageId: string;
41
+ signal?: AbortSignal;
42
+ };
43
+ export type RuntimeMessageRun = {
44
+ responseId: string;
45
+ runId: string;
46
+ status: RuntimeRunStatus;
47
+ reason: string | null;
48
+ };
49
+ export type RuntimeCancelRunParams = {
50
+ responseId: string;
51
+ runId: string;
52
+ reason?: 'user.cancelled' | 'client.unsync';
53
+ signal?: AbortSignal;
54
+ };
55
+ export type RuntimeCancelRunResult = {
56
+ responseId: string;
57
+ runId: string;
58
+ status: Extract<RuntimeRunStatus, 'cancelled'>;
59
+ };
60
+ export type RuntimeCommitToolOutputsParams = {
61
+ responseId: string;
62
+ runId: string;
63
+ toolOutputs: RuntimeToolOutputCommitRequest[];
64
+ signal?: AbortSignal;
65
+ };
66
+ export type RuntimeApi = {
67
+ getConfiguration: () => Promise<RuntimeResult<RuntimeConfiguration>>;
68
+ getRemainingLimits: () => Promise<RuntimeResult<RuntimeRemainingLimits>>;
69
+ getSessions: (_?: RuntimeGetSessionsParams) => Promise<RuntimeResult<SessionPage>>;
70
+ createSession: (_?: RuntimeCreateSessionParams) => Promise<RuntimeResult<Session>>;
71
+ getSession: (_: string) => Promise<RuntimeResult<Session>>;
72
+ deleteSession: (_: string) => Promise<RuntimeResult<void>>;
73
+ setSessionStar: (_: {
74
+ sessionId: string;
75
+ starred: boolean;
76
+ }) => Promise<RuntimeResult<SessionStar>>;
77
+ getSessionMessages: (_: RuntimeGetSessionMessagesParams) => Promise<RuntimeResult<RuntimeMessagePage>>;
78
+ setMessageFeedback: (_: RuntimeSetMessageFeedbackParams) => Promise<RuntimeResult<MessageFeedback>>;
79
+ recordTelemetryEvents: (_: RuntimeTelemetryEvent[]) => Promise<RuntimeResult<void>>;
80
+ createResponse: (_: RuntimeCreateResponseParams) => Promise<RuntimeResult<RuntimeCreateResponseResult>>;
81
+ getSessionMessageRun: (_: RuntimeGetSessionMessageRunParams) => Promise<RuntimeResult<RuntimeMessageRun | null>>;
82
+ continueRun: (_: RuntimeContinueRunParams) => Promise<RuntimeResult<RuntimeContinueRunResult>>;
83
+ cancelRun: (_: RuntimeCancelRunParams) => Promise<RuntimeResult<RuntimeCancelRunResult>>;
84
+ streamRunEvents: (_: RuntimeStreamRunEventsParams) => Promise<RuntimeResult<RuntimeRunEventStream>>;
85
+ claimToolCall: (_: RuntimeToolClaimRequest) => Promise<RuntimeResult<RuntimeToolClaim>>;
86
+ renewToolClaim: (_: RuntimeToolClaimRenewParams) => Promise<RuntimeResult<RuntimeToolClaim>>;
87
+ commitToolOutputs: (_: RuntimeCommitToolOutputsParams) => Promise<RuntimeResult<void>>;
88
+ };
@@ -0,0 +1,16 @@
1
+ export type Session = {
2
+ id: string;
3
+ title: string | null;
4
+ starred: boolean;
5
+ lastActivityAt: Date;
6
+ createdAt: Date;
7
+ updatedAt: Date;
8
+ };
9
+ export type SessionPage = {
10
+ items: Session[];
11
+ nextCursor: string | null;
12
+ };
13
+ export type SessionStar = {
14
+ sessionId: string;
15
+ starred: boolean;
16
+ };
@@ -0,0 +1,13 @@
1
+ import { Session, SessionPage, SessionStar } from './session';
2
+ export type RuntimeSession = Session;
3
+ export type RuntimeSessionPage = SessionPage;
4
+ export type RuntimeSessionStar = SessionStar;
5
+ export type RuntimeGetSessionsParams = {
6
+ limit?: number;
7
+ cursor?: string;
8
+ starred?: boolean;
9
+ query?: string;
10
+ };
11
+ export type RuntimeCreateSessionParams = {
12
+ title?: string;
13
+ };
@@ -0,0 +1 @@
1
+ export type RuntimeResult<T, E extends Error = Error> = readonly [T, null] | readonly [null, E];
@@ -0,0 +1,7 @@
1
+ export type MessageStatusCode = 'in_progress' | 'waiting_tool_outputs' | 'completed' | 'interrupted' | 'failed';
2
+ export type MessageStatusReason = 'system.started' | 'system.resumed' | 'system.awaiting_tool_outputs' | 'system.timeout' | 'system.resume_unavailable' | 'system.internal_error' | 'system.network_error' | 'system.stream_corrupted' | 'system.runtime_protocol_violation' | 'system.lease_expired' | 'user.cancelled' | 'provider.stop' | 'provider.max_tokens' | 'provider.content_filtered' | 'provider.other_finish_reason' | 'provider.error';
3
+ export type MessageStatus = {
4
+ version: 1;
5
+ code: MessageStatusCode;
6
+ reason: MessageStatusReason;
7
+ };
package/dist/tool.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { Schema } from 'ai';
2
+ import { default as z } from 'zod/v4';
3
+ export type ToolSignature = {
4
+ description: string;
5
+ claim?: 'required' | 'optional' | undefined;
6
+ inputSchema: Schema;
7
+ outputSchema: Schema;
8
+ };
9
+ export type ToolSignatures = Record<string, ToolSignature>;
10
+ export type Tools = Record<string, Tool>;
11
+ export interface Tool<I extends z.ZodTypeAny = z.ZodTypeAny, O extends z.ZodTypeAny = z.ZodTypeAny> {
12
+ description: string;
13
+ claim?: 'required' | 'optional' | undefined;
14
+ inputSchema: I;
15
+ outputSchema: O;
16
+ execute: (props: ToolExecuteProps<I>) => Promise<z.infer<O>>;
17
+ }
18
+ export interface ToolExecuteProps<Input extends z.ZodTypeAny> {
19
+ toolCallId: string;
20
+ input: z.infer<Input>;
21
+ }
22
+ export declare function createTool<I extends z.ZodTypeAny, O extends z.ZodTypeAny>(tool: Tool<I, O>): Tool<I, O>;
@@ -0,0 +1,39 @@
1
+ export type RuntimeToolClaimPolicy = 'required' | 'optional';
2
+ export type RuntimeToolSignature = {
3
+ description: string;
4
+ claim?: RuntimeToolClaimPolicy | undefined;
5
+ inputSchema: {
6
+ jsonSchema: Record<string, unknown>;
7
+ };
8
+ outputSchema: {
9
+ jsonSchema: Record<string, unknown>;
10
+ };
11
+ };
12
+ export type RuntimeToolClaim = {
13
+ toolCallId: string;
14
+ claimToken: string;
15
+ claimExpiresAt: Date;
16
+ operationKey: string;
17
+ claim: RuntimeToolClaimPolicy;
18
+ };
19
+ export type RuntimeToolOutputOutcome = 'success' | 'error' | 'denied';
20
+ export type RuntimeToolOutputCommitRequest = {
21
+ toolCallId: string;
22
+ claimToken?: string;
23
+ outcome: RuntimeToolOutputOutcome;
24
+ output?: unknown;
25
+ error?: string;
26
+ };
27
+ export type RuntimeToolClaimRequest = {
28
+ responseId: string;
29
+ runId: string;
30
+ toolCallId: string;
31
+ signal?: AbortSignal;
32
+ };
33
+ export type RuntimeToolClaimRenewParams = {
34
+ responseId: string;
35
+ runId: string;
36
+ toolCallId: string;
37
+ claimToken: string;
38
+ signal?: AbortSignal;
39
+ };
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@assistant-wi/core",
3
+ "private": false,
4
+ "version": "0.0.1-alpha.7",
5
+ "type": "module",
6
+ "description": "Core runtime contracts, tool authoring primitives, and message DTOs for assistant-wi",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "main": "./dist/index.cjs.js",
11
+ "module": "./dist/index.es.js",
12
+ "types": "./dist/index.d.ts",
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.es.js",
20
+ "require": "./dist/index.cjs.js",
21
+ "default": "./dist/index.es.js"
22
+ },
23
+ "./package.json": "./package.json"
24
+ },
25
+ "scripts": {
26
+ "build": "tsc -p tsconfig.json --noEmit && vite build -c vite.config.ts",
27
+ "test": "bun test src"
28
+ },
29
+ "dependencies": {
30
+ "ai": "6",
31
+ "zod": "^4.3.6"
32
+ },
33
+ "devDependencies": {
34
+ "@tsconfig/strictest": "^2.0.8",
35
+ "@types/bun": "^1.3.9",
36
+ "typescript": "^5.9.3",
37
+ "vite": "^7.3.1",
38
+ "vite-plugin-dts": "^4.5.4"
39
+ }
40
+ }