@moxt-ai/mobius-sdk 0.0.100 → 0.0.102

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 (106) hide show
  1. package/dist/client.d.ts +1 -1
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +1 -1
  4. package/dist/client.js.map +1 -1
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/platform.d.ts +2 -2
  10. package/dist/platform.d.ts.map +1 -1
  11. package/dist/platform.js +2 -2
  12. package/dist/platform.js.map +1 -1
  13. package/dist/project-authentication.js +1 -1
  14. package/dist/project-authentication.js.map +1 -1
  15. package/dist/protocol/codecs/messages.d.ts +32 -0
  16. package/dist/protocol/codecs/messages.d.ts.map +1 -0
  17. package/dist/protocol/codecs/messages.js +249 -0
  18. package/dist/protocol/codecs/messages.js.map +1 -0
  19. package/dist/protocol/control-messages.d.ts +964 -0
  20. package/dist/protocol/control-messages.d.ts.map +1 -0
  21. package/dist/protocol/control-messages.js +754 -0
  22. package/dist/protocol/control-messages.js.map +1 -0
  23. package/dist/protocol/conversation-title.d.ts +2 -0
  24. package/dist/protocol/conversation-title.d.ts.map +1 -0
  25. package/dist/protocol/conversation-title.js +28 -0
  26. package/dist/protocol/conversation-title.js.map +1 -0
  27. package/dist/protocol/daemon-transport.d.ts +3979 -0
  28. package/dist/protocol/daemon-transport.d.ts.map +1 -0
  29. package/dist/protocol/daemon-transport.js +94 -0
  30. package/dist/protocol/daemon-transport.js.map +1 -0
  31. package/dist/protocol/identifier.d.ts +7 -0
  32. package/dist/protocol/identifier.d.ts.map +1 -0
  33. package/dist/protocol/identifier.js +11 -0
  34. package/dist/protocol/identifier.js.map +1 -0
  35. package/dist/protocol/index.d.ts +18 -0
  36. package/dist/protocol/index.d.ts.map +1 -0
  37. package/dist/protocol/index.js +18 -0
  38. package/dist/protocol/index.js.map +1 -0
  39. package/dist/protocol/messages.d.ts +67 -0
  40. package/dist/protocol/messages.d.ts.map +1 -0
  41. package/dist/protocol/messages.js +16 -0
  42. package/dist/protocol/messages.js.map +1 -0
  43. package/dist/protocol/mobius-api.d.ts +10 -0
  44. package/dist/protocol/mobius-api.d.ts.map +1 -0
  45. package/dist/protocol/mobius-api.js +23 -0
  46. package/dist/protocol/mobius-api.js.map +1 -0
  47. package/dist/protocol/native-sessions.d.ts +401 -0
  48. package/dist/protocol/native-sessions.d.ts.map +1 -0
  49. package/dist/protocol/native-sessions.js +154 -0
  50. package/dist/protocol/native-sessions.js.map +1 -0
  51. package/dist/protocol/project-location.d.ts +16 -0
  52. package/dist/protocol/project-location.d.ts.map +1 -0
  53. package/dist/protocol/project-location.js +6 -0
  54. package/dist/protocol/project-location.js.map +1 -0
  55. package/dist/protocol/prompt-usage.d.ts +76 -0
  56. package/dist/protocol/prompt-usage.d.ts.map +1 -0
  57. package/dist/protocol/prompt-usage.js +88 -0
  58. package/dist/protocol/prompt-usage.js.map +1 -0
  59. package/dist/protocol/resource-model.d.ts +339 -0
  60. package/dist/protocol/resource-model.d.ts.map +1 -0
  61. package/dist/protocol/resource-model.js +161 -0
  62. package/dist/protocol/resource-model.js.map +1 -0
  63. package/dist/protocol/runtime-diagnostics.d.ts +19 -0
  64. package/dist/protocol/runtime-diagnostics.d.ts.map +1 -0
  65. package/dist/protocol/runtime-diagnostics.js +24 -0
  66. package/dist/protocol/runtime-diagnostics.js.map +1 -0
  67. package/dist/protocol/runtime-upgrade.d.ts +29 -0
  68. package/dist/protocol/runtime-upgrade.d.ts.map +1 -0
  69. package/dist/protocol/runtime-upgrade.js +38 -0
  70. package/dist/protocol/runtime-upgrade.js.map +1 -0
  71. package/dist/protocol/session-access.d.ts +21 -0
  72. package/dist/protocol/session-access.d.ts.map +1 -0
  73. package/dist/protocol/session-access.js +108 -0
  74. package/dist/protocol/session-access.js.map +1 -0
  75. package/dist/protocol/session-event-log.d.ts +13542 -0
  76. package/dist/protocol/session-event-log.d.ts.map +1 -0
  77. package/dist/protocol/session-event-log.js +584 -0
  78. package/dist/protocol/session-event-log.js.map +1 -0
  79. package/dist/protocol/session-history.d.ts +2907 -0
  80. package/dist/protocol/session-history.d.ts.map +1 -0
  81. package/dist/protocol/session-history.js +58 -0
  82. package/dist/protocol/session-history.js.map +1 -0
  83. package/dist/protocol/session-recording.d.ts +5640 -0
  84. package/dist/protocol/session-recording.d.ts.map +1 -0
  85. package/dist/protocol/session-recording.js +365 -0
  86. package/dist/protocol/session-recording.js.map +1 -0
  87. package/dist/public-request.js +1 -1
  88. package/dist/public-request.js.map +1 -1
  89. package/dist/resources.d.ts +1 -1
  90. package/dist/resources.d.ts.map +1 -1
  91. package/dist/resources.js +1 -1
  92. package/dist/resources.js.map +1 -1
  93. package/dist/server.d.ts +2 -2
  94. package/dist/server.d.ts.map +1 -1
  95. package/dist/server.js +1 -1
  96. package/dist/server.js.map +1 -1
  97. package/dist/service-client.d.ts +19 -19
  98. package/dist/service-client.d.ts.map +1 -1
  99. package/dist/service-client.js +21 -23
  100. package/dist/service-client.js.map +1 -1
  101. package/dist/transport/http-transport.d.ts +1 -1
  102. package/dist/transport/http-transport.js +1 -1
  103. package/dist/transport/ws-transport.d.ts +1 -1
  104. package/dist/transport/ws-transport.js +2 -2
  105. package/dist/transport/ws-transport.js.map +1 -1
  106. package/package.json +8 -3
@@ -0,0 +1,76 @@
1
+ import { z } from "zod";
2
+ export declare const promptUsageSchema: z.ZodReadonly<z.ZodObject<{
3
+ cachedReadTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
4
+ cachedWriteTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
5
+ inputTokens: z.ZodNumber;
6
+ outputTokens: z.ZodNumber;
7
+ thoughtTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
8
+ totalTokens: z.ZodNumber;
9
+ }, z.core.$strip>>;
10
+ export declare const promptMetadataSchema: z.ZodReadonly<z.ZodObject<{
11
+ quota: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
12
+ model_usage: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
13
+ model: z.ZodString;
14
+ token_count: z.ZodPreprocess<z.ZodReadonly<z.ZodObject<{
15
+ cachedInputTokens: z.ZodOptional<z.ZodNumber>;
16
+ cachedWriteTokens: z.ZodOptional<z.ZodNumber>;
17
+ inputTokens: z.ZodNumber;
18
+ outputTokens: z.ZodNumber;
19
+ reasoningOutputTokens: z.ZodOptional<z.ZodNumber>;
20
+ totalTokens: z.ZodNumber;
21
+ }, z.core.$strip>>, unknown>;
22
+ }, z.core.$strip>>>>;
23
+ token_count: z.ZodNullable<z.ZodPreprocess<z.ZodReadonly<z.ZodObject<{
24
+ cachedInputTokens: z.ZodOptional<z.ZodNumber>;
25
+ cachedWriteTokens: z.ZodOptional<z.ZodNumber>;
26
+ inputTokens: z.ZodNumber;
27
+ outputTokens: z.ZodNumber;
28
+ reasoningOutputTokens: z.ZodOptional<z.ZodNumber>;
29
+ totalTokens: z.ZodNumber;
30
+ }, z.core.$strip>>, unknown>>;
31
+ }, z.core.$strip>>>;
32
+ }, z.core.$strip>>;
33
+ declare const agentPromptResponseSchema: z.ZodReadonly<z.ZodObject<{
34
+ _meta: z.ZodOptional<z.ZodNullable<z.ZodReadonly<z.ZodObject<{
35
+ quota: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
36
+ model_usage: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
37
+ model: z.ZodString;
38
+ token_count: z.ZodPreprocess<z.ZodReadonly<z.ZodObject<{
39
+ cachedInputTokens: z.ZodOptional<z.ZodNumber>;
40
+ cachedWriteTokens: z.ZodOptional<z.ZodNumber>;
41
+ inputTokens: z.ZodNumber;
42
+ outputTokens: z.ZodNumber;
43
+ reasoningOutputTokens: z.ZodOptional<z.ZodNumber>;
44
+ totalTokens: z.ZodNumber;
45
+ }, z.core.$strip>>, unknown>;
46
+ }, z.core.$strip>>>>;
47
+ token_count: z.ZodNullable<z.ZodPreprocess<z.ZodReadonly<z.ZodObject<{
48
+ cachedInputTokens: z.ZodOptional<z.ZodNumber>;
49
+ cachedWriteTokens: z.ZodOptional<z.ZodNumber>;
50
+ inputTokens: z.ZodNumber;
51
+ outputTokens: z.ZodNumber;
52
+ reasoningOutputTokens: z.ZodOptional<z.ZodNumber>;
53
+ totalTokens: z.ZodNumber;
54
+ }, z.core.$strip>>, unknown>>;
55
+ }, z.core.$strip>>>;
56
+ }, z.core.$strip>>>>;
57
+ stopReason: z.ZodEnum<{
58
+ cancelled: "cancelled";
59
+ end_turn: "end_turn";
60
+ max_tokens: "max_tokens";
61
+ max_turn_requests: "max_turn_requests";
62
+ refusal: "refusal";
63
+ }>;
64
+ usage: z.ZodOptional<z.ZodNullable<z.ZodReadonly<z.ZodObject<{
65
+ cachedReadTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
66
+ cachedWriteTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
67
+ inputTokens: z.ZodNumber;
68
+ outputTokens: z.ZodNumber;
69
+ thoughtTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
70
+ totalTokens: z.ZodNumber;
71
+ }, z.core.$strip>>>>;
72
+ }, z.core.$strip>>;
73
+ export type AgentPromptResponse = z.infer<typeof agentPromptResponseSchema>;
74
+ export declare function decodeAgentPromptResponse(value: unknown): AgentPromptResponse;
75
+ export {};
76
+ //# sourceMappingURL=prompt-usage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-usage.d.ts","sourceRoot":"","sources":["../../src/protocol/prompt-usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkCxB,eAAO,MAAM,iBAAiB;;;;;;;kBASf,CAAC;AAmBhB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;kBAoBlB,CAAC;AAEhB,QAAA,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAMhB,CAAC;AAEhB,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,CAQ7E"}
@@ -0,0 +1,88 @@
1
+ import { z } from "zod";
2
+ import { ProtocolMessageError } from "./codecs/messages.js";
3
+ const TOKEN_COUNT = z.number().int().nonnegative();
4
+ function normalizeQuotaTokenCount(value) {
5
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
6
+ return value;
7
+ }
8
+ if (Reflect.has(value, "inputTokens") || Reflect.has(value, "outputTokens") || Reflect.has(value, "totalTokens")) {
9
+ return value;
10
+ }
11
+ if (!Reflect.has(value, "input_tokens") && !Reflect.has(value, "output_tokens")) {
12
+ return value;
13
+ }
14
+ const inputTokens = Reflect.get(value, "input_tokens");
15
+ const outputTokens = Reflect.get(value, "output_tokens");
16
+ const reportedTotal = Reflect.get(value, "total_tokens");
17
+ return {
18
+ cachedInputTokens: Reflect.get(value, "cached_input_tokens"),
19
+ cachedWriteTokens: Reflect.get(value, "cached_write_tokens"),
20
+ inputTokens,
21
+ outputTokens,
22
+ reasoningOutputTokens: Reflect.get(value, "reasoning_output_tokens"),
23
+ totalTokens: reportedTotal === undefined && typeof inputTokens === "number" && typeof outputTokens === "number"
24
+ ? inputTokens + outputTokens
25
+ : reportedTotal,
26
+ };
27
+ }
28
+ // Adapter-reported snapshots, not deltas. Cache and reasoning counters can
29
+ // overlap other counters; consumers must not sum fields or successive reports.
30
+ export const promptUsageSchema = z
31
+ .object({
32
+ cachedReadTokens: TOKEN_COUNT.nullish(),
33
+ cachedWriteTokens: TOKEN_COUNT.nullish(),
34
+ inputTokens: TOKEN_COUNT,
35
+ outputTokens: TOKEN_COUNT,
36
+ thoughtTokens: TOKEN_COUNT.nullish(),
37
+ totalTokens: TOKEN_COUNT,
38
+ })
39
+ .readonly();
40
+ const quotaTokenCountSchema = z.preprocess(normalizeQuotaTokenCount, z
41
+ .object({
42
+ cachedInputTokens: TOKEN_COUNT.optional(),
43
+ cachedWriteTokens: TOKEN_COUNT.optional(),
44
+ inputTokens: TOKEN_COUNT,
45
+ outputTokens: TOKEN_COUNT,
46
+ reasoningOutputTokens: TOKEN_COUNT.optional(),
47
+ totalTokens: TOKEN_COUNT,
48
+ })
49
+ .readonly());
50
+ // Codex ACP 1.8.0 and Claude ACP 0.73.0 report camel-case quota counters.
51
+ // Gemini CLI 0.59.0 reports bounded snake-case input/output counters instead.
52
+ // Claude model rows can include subagents, so they need not sum to token_count.
53
+ export const promptMetadataSchema = z
54
+ .object({
55
+ quota: z
56
+ .object({
57
+ model_usage: z
58
+ .array(z
59
+ .object({
60
+ model: z.string().min(1).max(255),
61
+ token_count: quotaTokenCountSchema,
62
+ })
63
+ .readonly())
64
+ .max(100)
65
+ .readonly(),
66
+ token_count: quotaTokenCountSchema.nullable(),
67
+ })
68
+ .readonly()
69
+ .optional(),
70
+ })
71
+ .readonly();
72
+ const agentPromptResponseSchema = z
73
+ .object({
74
+ _meta: promptMetadataSchema.nullish(),
75
+ stopReason: z.enum(["end_turn", "max_tokens", "max_turn_requests", "refusal", "cancelled"]),
76
+ usage: promptUsageSchema.nullish(),
77
+ })
78
+ .readonly();
79
+ export function decodeAgentPromptResponse(value) {
80
+ const result = agentPromptResponseSchema.safeParse(value);
81
+ if (!result.success) {
82
+ throw new ProtocolMessageError("Invalid agent prompt response", {
83
+ cause: result.error,
84
+ });
85
+ }
86
+ return result.data;
87
+ }
88
+ //# sourceMappingURL=prompt-usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-usage.js","sourceRoot":"","sources":["../../src/protocol/prompt-usage.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,339 @@
1
+ import { z } from "zod";
2
+ export declare const MAX_LOCAL_AGENT_DIRECTORY_ENTRIES = 32;
3
+ declare const turnStateSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
4
+ kind: z.ZodLiteral<"queued">;
5
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
6
+ kind: z.ZodLiteral<"running">;
7
+ startedAt: z.ZodString;
8
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
9
+ completedAt: z.ZodString;
10
+ kind: z.ZodLiteral<"succeeded">;
11
+ result: z.ZodReadonly<z.ZodObject<{
12
+ kind: z.ZodLiteral<"agent_result">;
13
+ stopReason: z.ZodString;
14
+ }, z.core.$strip>>;
15
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
16
+ error: z.ZodReadonly<z.ZodObject<{
17
+ code: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
18
+ message: z.ZodString;
19
+ retryable: z.ZodBoolean;
20
+ }, z.core.$strip>>;
21
+ failedAt: z.ZodString;
22
+ kind: z.ZodLiteral<"failed">;
23
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
24
+ cancelledAt: z.ZodString;
25
+ kind: z.ZodLiteral<"cancelled">;
26
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
27
+ kind: z.ZodLiteral<"indeterminate">;
28
+ reconciliation: z.ZodReadonly<z.ZodObject<{
29
+ detectedAt: z.ZodString;
30
+ reason: z.ZodEnum<{
31
+ connection_lost: "connection_lost";
32
+ dispatch_indeterminate: "dispatch_indeterminate";
33
+ runtime_restarted: "runtime_restarted";
34
+ }>;
35
+ }, z.core.$strip>>;
36
+ }, z.core.$strip>>], "kind">;
37
+ export type TurnState = z.infer<typeof turnStateSchema>;
38
+ declare const turnRequestSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
39
+ content: z.ZodString;
40
+ kind: z.ZodLiteral<"prompt">;
41
+ sessionConfigurations: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
42
+ booleanValue: z.ZodBoolean;
43
+ configId: z.ZodString;
44
+ value: z.ZodString;
45
+ valueType: z.ZodEnum<{
46
+ boolean: "boolean";
47
+ select: "select";
48
+ }>;
49
+ }, z.core.$strip>>>>>;
50
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
51
+ kind: z.ZodLiteral<"not_retained">;
52
+ }, z.core.$strip>>], "kind">;
53
+ export type TurnRequest = z.infer<typeof turnRequestSchema>;
54
+ declare const turnSchema: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
55
+ acceptedAt: z.ZodString;
56
+ bindingId: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
57
+ idempotencyKey: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
58
+ sessionId: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
59
+ turnId: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
60
+ request: z.ZodReadonly<z.ZodObject<{
61
+ content: z.ZodString;
62
+ kind: z.ZodLiteral<"prompt">;
63
+ sessionConfigurations: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
64
+ booleanValue: z.ZodBoolean;
65
+ configId: z.ZodString;
66
+ value: z.ZodString;
67
+ valueType: z.ZodEnum<{
68
+ boolean: "boolean";
69
+ select: "select";
70
+ }>;
71
+ }, z.core.$strip>>>>>;
72
+ }, z.core.$strip>>;
73
+ state: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
74
+ kind: z.ZodLiteral<"queued">;
75
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
76
+ kind: z.ZodLiteral<"running">;
77
+ startedAt: z.ZodString;
78
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
79
+ completedAt: z.ZodString;
80
+ kind: z.ZodLiteral<"succeeded">;
81
+ result: z.ZodReadonly<z.ZodObject<{
82
+ kind: z.ZodLiteral<"agent_result">;
83
+ stopReason: z.ZodString;
84
+ }, z.core.$strip>>;
85
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
86
+ error: z.ZodReadonly<z.ZodObject<{
87
+ code: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
88
+ message: z.ZodString;
89
+ retryable: z.ZodBoolean;
90
+ }, z.core.$strip>>;
91
+ failedAt: z.ZodString;
92
+ kind: z.ZodLiteral<"failed">;
93
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
94
+ cancelledAt: z.ZodString;
95
+ kind: z.ZodLiteral<"cancelled">;
96
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
97
+ kind: z.ZodLiteral<"indeterminate">;
98
+ reconciliation: z.ZodReadonly<z.ZodObject<{
99
+ detectedAt: z.ZodString;
100
+ reason: z.ZodEnum<{
101
+ connection_lost: "connection_lost";
102
+ dispatch_indeterminate: "dispatch_indeterminate";
103
+ runtime_restarted: "runtime_restarted";
104
+ }>;
105
+ }, z.core.$strip>>;
106
+ }, z.core.$strip>>], "kind">;
107
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
108
+ acceptedAt: z.ZodString;
109
+ bindingId: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
110
+ idempotencyKey: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
111
+ sessionId: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
112
+ turnId: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
113
+ request: z.ZodReadonly<z.ZodObject<{
114
+ kind: z.ZodLiteral<"not_retained">;
115
+ }, z.core.$strip>>;
116
+ state: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
117
+ completedAt: z.ZodString;
118
+ kind: z.ZodLiteral<"succeeded">;
119
+ result: z.ZodReadonly<z.ZodObject<{
120
+ kind: z.ZodLiteral<"agent_result">;
121
+ stopReason: z.ZodString;
122
+ }, z.core.$strip>>;
123
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
124
+ error: z.ZodReadonly<z.ZodObject<{
125
+ code: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
126
+ message: z.ZodString;
127
+ retryable: z.ZodBoolean;
128
+ }, z.core.$strip>>;
129
+ failedAt: z.ZodString;
130
+ kind: z.ZodLiteral<"failed">;
131
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
132
+ cancelledAt: z.ZodString;
133
+ kind: z.ZodLiteral<"cancelled">;
134
+ }, z.core.$strip>>], "kind">;
135
+ }, z.core.$strip>>]>;
136
+ export type Turn = z.infer<typeof turnSchema>;
137
+ declare const interactionRequestSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
138
+ kind: z.ZodLiteral<"permission">;
139
+ options: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
140
+ kind: z.ZodEnum<{
141
+ allow_always: "allow_always";
142
+ allow_once: "allow_once";
143
+ reject_always: "reject_always";
144
+ reject_once: "reject_once";
145
+ }>;
146
+ name: z.ZodString;
147
+ optionId: z.ZodString;
148
+ }, z.core.$strip>>>>;
149
+ title: z.ZodString;
150
+ toolCallId: z.ZodString;
151
+ toolKind: z.ZodString;
152
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
153
+ elicitationId: z.ZodString;
154
+ fields: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
155
+ defaultBooleanValue: z.ZodBoolean;
156
+ defaultNumberValue: z.ZodNumber;
157
+ defaultStringValue: z.ZodString;
158
+ description: z.ZodString;
159
+ format: z.ZodString;
160
+ hasDefaultValue: z.ZodBoolean;
161
+ maximum: z.ZodString;
162
+ maximumLength: z.ZodString;
163
+ minimum: z.ZodString;
164
+ minimumLength: z.ZodString;
165
+ name: z.ZodString;
166
+ options: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
167
+ description: z.ZodString;
168
+ label: z.ZodString;
169
+ value: z.ZodString;
170
+ }, z.core.$strip>>>>;
171
+ pattern: z.ZodString;
172
+ required: z.ZodBoolean;
173
+ title: z.ZodString;
174
+ type: z.ZodEnum<{
175
+ boolean: "boolean";
176
+ integer: "integer";
177
+ multiselect: "multiselect";
178
+ number: "number";
179
+ select: "select";
180
+ string: "string";
181
+ }>;
182
+ }, z.core.$strip>>>>;
183
+ kind: z.ZodLiteral<"elicitation">;
184
+ message: z.ZodString;
185
+ mode: z.ZodEnum<{
186
+ form: "form";
187
+ url: "url";
188
+ }>;
189
+ url: z.ZodString;
190
+ }, z.core.$strip>>], "kind">;
191
+ export type InteractionRequest = z.infer<typeof interactionRequestSchema>;
192
+ declare const interactionResponseSchema: z.ZodReadonly<z.ZodObject<{
193
+ content: z.ZodString;
194
+ kind: z.ZodEnum<{
195
+ elicitation: "elicitation";
196
+ permission: "permission";
197
+ }>;
198
+ }, z.core.$strip>>;
199
+ export type InteractionResponse = z.infer<typeof interactionResponseSchema>;
200
+ declare const interactionStateSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
201
+ kind: z.ZodLiteral<"pending">;
202
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
203
+ kind: z.ZodLiteral<"responded">;
204
+ respondedAt: z.ZodString;
205
+ responderId: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
206
+ response: z.ZodReadonly<z.ZodObject<{
207
+ content: z.ZodString;
208
+ kind: z.ZodEnum<{
209
+ elicitation: "elicitation";
210
+ permission: "permission";
211
+ }>;
212
+ }, z.core.$strip>>;
213
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
214
+ kind: z.ZodLiteral<"resolved">;
215
+ resolution: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
216
+ kind: z.ZodLiteral<"without_response">;
217
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
218
+ kind: z.ZodLiteral<"response_applied">;
219
+ respondedAt: z.ZodString;
220
+ responderId: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
221
+ response: z.ZodReadonly<z.ZodObject<{
222
+ content: z.ZodString;
223
+ kind: z.ZodEnum<{
224
+ elicitation: "elicitation";
225
+ permission: "permission";
226
+ }>;
227
+ }, z.core.$strip>>;
228
+ }, z.core.$strip>>], "kind">;
229
+ resolvedAt: z.ZodString;
230
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
231
+ expiredAt: z.ZodString;
232
+ kind: z.ZodLiteral<"expired">;
233
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
234
+ cancelledAt: z.ZodString;
235
+ kind: z.ZodLiteral<"cancelled">;
236
+ }, z.core.$strip>>], "kind">;
237
+ export type InteractionState = z.infer<typeof interactionStateSchema>;
238
+ declare const interactionSchema: z.ZodReadonly<z.ZodObject<{
239
+ attemptId: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
240
+ interactionId: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
241
+ request: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
242
+ kind: z.ZodLiteral<"permission">;
243
+ options: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
244
+ kind: z.ZodEnum<{
245
+ allow_always: "allow_always";
246
+ allow_once: "allow_once";
247
+ reject_always: "reject_always";
248
+ reject_once: "reject_once";
249
+ }>;
250
+ name: z.ZodString;
251
+ optionId: z.ZodString;
252
+ }, z.core.$strip>>>>;
253
+ title: z.ZodString;
254
+ toolCallId: z.ZodString;
255
+ toolKind: z.ZodString;
256
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
257
+ elicitationId: z.ZodString;
258
+ fields: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
259
+ defaultBooleanValue: z.ZodBoolean;
260
+ defaultNumberValue: z.ZodNumber;
261
+ defaultStringValue: z.ZodString;
262
+ description: z.ZodString;
263
+ format: z.ZodString;
264
+ hasDefaultValue: z.ZodBoolean;
265
+ maximum: z.ZodString;
266
+ maximumLength: z.ZodString;
267
+ minimum: z.ZodString;
268
+ minimumLength: z.ZodString;
269
+ name: z.ZodString;
270
+ options: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
271
+ description: z.ZodString;
272
+ label: z.ZodString;
273
+ value: z.ZodString;
274
+ }, z.core.$strip>>>>;
275
+ pattern: z.ZodString;
276
+ required: z.ZodBoolean;
277
+ title: z.ZodString;
278
+ type: z.ZodEnum<{
279
+ boolean: "boolean";
280
+ integer: "integer";
281
+ multiselect: "multiselect";
282
+ number: "number";
283
+ select: "select";
284
+ string: "string";
285
+ }>;
286
+ }, z.core.$strip>>>>;
287
+ kind: z.ZodLiteral<"elicitation">;
288
+ message: z.ZodString;
289
+ mode: z.ZodEnum<{
290
+ form: "form";
291
+ url: "url";
292
+ }>;
293
+ url: z.ZodString;
294
+ }, z.core.$strip>>], "kind">;
295
+ sessionId: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
296
+ state: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
297
+ kind: z.ZodLiteral<"pending">;
298
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
299
+ kind: z.ZodLiteral<"responded">;
300
+ respondedAt: z.ZodString;
301
+ responderId: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
302
+ response: z.ZodReadonly<z.ZodObject<{
303
+ content: z.ZodString;
304
+ kind: z.ZodEnum<{
305
+ elicitation: "elicitation";
306
+ permission: "permission";
307
+ }>;
308
+ }, z.core.$strip>>;
309
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
310
+ kind: z.ZodLiteral<"resolved">;
311
+ resolution: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
312
+ kind: z.ZodLiteral<"without_response">;
313
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
314
+ kind: z.ZodLiteral<"response_applied">;
315
+ respondedAt: z.ZodString;
316
+ responderId: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
317
+ response: z.ZodReadonly<z.ZodObject<{
318
+ content: z.ZodString;
319
+ kind: z.ZodEnum<{
320
+ elicitation: "elicitation";
321
+ permission: "permission";
322
+ }>;
323
+ }, z.core.$strip>>;
324
+ }, z.core.$strip>>], "kind">;
325
+ resolvedAt: z.ZodString;
326
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
327
+ expiredAt: z.ZodString;
328
+ kind: z.ZodLiteral<"expired">;
329
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
330
+ cancelledAt: z.ZodString;
331
+ kind: z.ZodLiteral<"cancelled">;
332
+ }, z.core.$strip>>], "kind">;
333
+ turnId: z.core.$ZodBranded<z.ZodString, "Identifier", "out">;
334
+ }, z.core.$strip>>;
335
+ export type Interaction = z.infer<typeof interactionSchema>;
336
+ export declare const decodeTurn: (value: unknown) => Turn;
337
+ export declare const decodeInteraction: (value: unknown) => Interaction;
338
+ export {};
339
+ //# sourceMappingURL=resource-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-model.d.ts","sourceRoot":"","sources":["../../src/protocol/resource-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,eAAO,MAAM,iCAAiC,KAAK,CAAC;AAiDpD,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAUnB,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAUxD,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;4BAAwF,CAAC;AAEhH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAS5D,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAGd,CAAC;AAEH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAuB9C,QAAA,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAAoF,CAAC;AAEnH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,QAAA,MAAM,yBAAyB;;;;;;kBAKhB,CAAC;AAEhB,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,QAAA,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAkC1B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBASR,CAAC;AAEhB,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAY5D,eAAO,MAAM,UAAU,UAAW,OAAO,KAAG,IAAyC,CAAC;AACtF,eAAO,MAAM,iBAAiB,UAAW,OAAO,KAAG,WAAuD,CAAC"}
@@ -0,0 +1,161 @@
1
+ import { z } from "zod";
2
+ import { ProtocolMessageError } from "./codecs/messages.js";
3
+ import { elicitationFieldSchema, permissionOptionSchema, sessionConfigurationSelectionsSchema, } from "./control-messages.js";
4
+ import { identifierSchema } from "./identifier.js";
5
+ export const MAX_LOCAL_AGENT_DIRECTORY_ENTRIES = 32;
6
+ const timestampSchema = z.string().datetime({ offset: true });
7
+ const domainErrorSchema = z
8
+ .object({
9
+ code: identifierSchema,
10
+ message: z.string().min(1).max(2_000),
11
+ retryable: z.boolean(),
12
+ })
13
+ .readonly();
14
+ const executionResultSchema = z
15
+ .object({
16
+ kind: z.literal("agent_result"),
17
+ stopReason: z.string().min(1).max(128),
18
+ })
19
+ .readonly();
20
+ const reconciliationSchema = z
21
+ .object({
22
+ detectedAt: timestampSchema,
23
+ reason: z.enum(["connection_lost", "dispatch_indeterminate", "runtime_restarted"]),
24
+ })
25
+ .readonly();
26
+ const terminalTurnStateSchema = z.discriminatedUnion("kind", [
27
+ z
28
+ .object({
29
+ completedAt: timestampSchema,
30
+ kind: z.literal("succeeded"),
31
+ result: executionResultSchema,
32
+ })
33
+ .readonly(),
34
+ z
35
+ .object({
36
+ error: domainErrorSchema,
37
+ failedAt: timestampSchema,
38
+ kind: z.literal("failed"),
39
+ })
40
+ .readonly(),
41
+ z
42
+ .object({
43
+ cancelledAt: timestampSchema,
44
+ kind: z.literal("cancelled"),
45
+ })
46
+ .readonly(),
47
+ ]);
48
+ const turnStateSchema = z.discriminatedUnion("kind", [
49
+ z.object({ kind: z.literal("queued") }).readonly(),
50
+ z.object({ kind: z.literal("running"), startedAt: timestampSchema }).readonly(),
51
+ ...terminalTurnStateSchema.options,
52
+ z
53
+ .object({
54
+ kind: z.literal("indeterminate"),
55
+ reconciliation: reconciliationSchema,
56
+ })
57
+ .readonly(),
58
+ ]);
59
+ const promptTurnRequestSchema = z
60
+ .object({
61
+ content: z.string().max(100_000),
62
+ kind: z.literal("prompt"),
63
+ sessionConfigurations: sessionConfigurationSelectionsSchema.default([]),
64
+ })
65
+ .readonly();
66
+ const notRetainedTurnRequestSchema = z.object({ kind: z.literal("not_retained") }).readonly();
67
+ const turnRequestSchema = z.discriminatedUnion("kind", [promptTurnRequestSchema, notRetainedTurnRequestSchema]);
68
+ const turnIdentitySchema = z.object({
69
+ acceptedAt: timestampSchema,
70
+ bindingId: identifierSchema,
71
+ idempotencyKey: identifierSchema,
72
+ sessionId: identifierSchema,
73
+ turnId: identifierSchema,
74
+ });
75
+ const turnSchema = z.union([
76
+ turnIdentitySchema.extend({ request: promptTurnRequestSchema, state: turnStateSchema }).readonly(),
77
+ turnIdentitySchema.extend({ request: notRetainedTurnRequestSchema, state: terminalTurnStateSchema }).readonly(),
78
+ ]);
79
+ const permissionRequestSchema = z
80
+ .object({
81
+ kind: z.literal("permission"),
82
+ options: z.array(permissionOptionSchema).min(1).max(20).readonly(),
83
+ title: z.string().min(1).max(500),
84
+ toolCallId: z.string().min(1).max(255),
85
+ toolKind: z.string().max(64),
86
+ })
87
+ .readonly();
88
+ const elicitationRequestSchema = z
89
+ .object({
90
+ elicitationId: z.string().max(255),
91
+ fields: z.array(elicitationFieldSchema).max(100).readonly(),
92
+ kind: z.literal("elicitation"),
93
+ message: z.string().min(1).max(2_000),
94
+ mode: z.enum(["form", "url"]),
95
+ url: z.string().max(4_096),
96
+ })
97
+ .readonly();
98
+ const interactionRequestSchema = z.discriminatedUnion("kind", [permissionRequestSchema, elicitationRequestSchema]);
99
+ const interactionResponseSchema = z
100
+ .object({
101
+ content: z.string().max(100_000),
102
+ kind: z.enum(["permission", "elicitation"]),
103
+ })
104
+ .readonly();
105
+ const interactionStateSchema = z.discriminatedUnion("kind", [
106
+ z.object({ kind: z.literal("pending") }).readonly(),
107
+ z
108
+ .object({
109
+ kind: z.literal("responded"),
110
+ respondedAt: timestampSchema,
111
+ responderId: identifierSchema,
112
+ response: interactionResponseSchema,
113
+ })
114
+ .readonly(),
115
+ z
116
+ .object({
117
+ kind: z.literal("resolved"),
118
+ resolution: z.discriminatedUnion("kind", [
119
+ z.object({ kind: z.literal("without_response") }).readonly(),
120
+ z
121
+ .object({
122
+ kind: z.literal("response_applied"),
123
+ respondedAt: timestampSchema,
124
+ responderId: identifierSchema,
125
+ response: interactionResponseSchema,
126
+ })
127
+ .readonly(),
128
+ ]),
129
+ resolvedAt: timestampSchema,
130
+ })
131
+ .readonly(),
132
+ z.object({ expiredAt: timestampSchema, kind: z.literal("expired") }).readonly(),
133
+ z
134
+ .object({
135
+ cancelledAt: timestampSchema,
136
+ kind: z.literal("cancelled"),
137
+ })
138
+ .readonly(),
139
+ ]);
140
+ const interactionSchema = z
141
+ .object({
142
+ attemptId: identifierSchema,
143
+ interactionId: identifierSchema,
144
+ request: interactionRequestSchema,
145
+ sessionId: identifierSchema,
146
+ state: interactionStateSchema,
147
+ turnId: identifierSchema,
148
+ })
149
+ .readonly();
150
+ function decodeResource(value, schema) {
151
+ const decoded = schema.safeParse(value);
152
+ if (!decoded.success) {
153
+ throw new ProtocolMessageError("Resource does not match its schema", {
154
+ cause: decoded.error,
155
+ });
156
+ }
157
+ return decoded.data;
158
+ }
159
+ export const decodeTurn = (value) => decodeResource(value, turnSchema);
160
+ export const decodeInteraction = (value) => decodeResource(value, interactionSchema);
161
+ //# sourceMappingURL=resource-model.js.map