@mininglamp-oss/octo-runtime-client 0.0.0-stage → 1.1.11

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 (87) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +38 -2
  3. package/build-info.json +5 -0
  4. package/dist/async-question-reply.d.ts +30 -0
  5. package/dist/async-question-reply.js +199 -0
  6. package/dist/browser.d.ts +1 -0
  7. package/dist/browser.js +1 -0
  8. package/dist/client.d.ts +10 -0
  9. package/dist/client.js +465 -0
  10. package/dist/index.d.ts +6 -0
  11. package/dist/index.js +6 -0
  12. package/dist/internal.d.ts +4 -0
  13. package/dist/internal.js +5 -0
  14. package/dist/invocation-lifecycle.d.ts +59 -0
  15. package/dist/invocation-lifecycle.js +287 -0
  16. package/dist/notification.d.ts +1 -0
  17. package/dist/notification.js +1 -0
  18. package/dist/protocol.d.ts +1 -0
  19. package/dist/protocol.js +1 -0
  20. package/dist/runtime-path.d.ts +21 -0
  21. package/dist/runtime-path.js +138 -0
  22. package/dist/startup-catalog.d.ts +8 -0
  23. package/dist/startup-catalog.js +65 -0
  24. package/dist/startup-diagnostics.d.ts +82 -0
  25. package/dist/startup-diagnostics.js +371 -0
  26. package/dist/submission-error.d.ts +10 -0
  27. package/dist/submission-error.js +23 -0
  28. package/dist/types.d.ts +72 -0
  29. package/dist/types.js +10 -0
  30. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/actmode.d.ts +4 -0
  31. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/actmode.js +36 -0
  32. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.d.ts +7 -0
  33. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.js +1 -0
  34. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.d.ts +7 -0
  35. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.js +6 -0
  36. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.d.ts +11 -0
  37. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.js +33 -0
  38. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-configuration.d.ts +5 -0
  39. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-configuration.js +58 -0
  40. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-hash.d.ts +2 -0
  41. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-hash.js +5 -0
  42. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.d.ts +29 -0
  43. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +566 -0
  44. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/execution-plan.d.ts +3 -0
  45. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/execution-plan.js +80 -0
  46. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/experience.d.ts +4 -0
  47. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/experience.js +166 -0
  48. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.d.ts +82 -0
  49. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +562 -0
  50. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +3022 -0
  51. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.js +6 -0
  52. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +124 -0
  53. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +709 -0
  54. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.d.ts +129 -0
  55. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.js +177 -0
  56. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-size.d.ts +3 -0
  57. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-size.js +11 -0
  58. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/json-size.d.ts +2 -0
  59. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/json-size.js +91 -0
  60. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/model-context.d.ts +3 -0
  61. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/model-context.js +9 -0
  62. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/multimodal.d.ts +15 -0
  63. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/multimodal.js +166 -0
  64. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/notification.d.ts +2 -0
  65. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/notification.js +137 -0
  66. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/questions.d.ts +9 -0
  67. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/questions.js +84 -0
  68. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.d.ts +20 -0
  69. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.js +294 -0
  70. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/runtime-selection.d.ts +3 -0
  71. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/runtime-selection.js +68 -0
  72. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.d.ts +5 -0
  73. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.js +65 -0
  74. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/stream-limits.d.ts +27 -0
  75. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/stream-limits.js +56 -0
  76. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +15 -0
  77. package/package.json +55 -4
  78. package/schema/context-configuration-fixtures.json +1219 -0
  79. package/schema/context-fixtures.json +5988 -0
  80. package/schema/kernel-client.behavior.json +56 -0
  81. package/schema/kernel-ipc-fixtures.json +53 -0
  82. package/schema/kernel-ipc.schema.json +538 -0
  83. package/schema/native-invoke-fixtures.json +116 -0
  84. package/schema/protocol.schema.json +4525 -0
  85. package/schema/run-protocol-fixtures.json +761 -0
  86. package/schema/runtime-selection-fixtures.json +663 -0
  87. package/schema/session-name-fixtures.json +191 -0
@@ -0,0 +1,6 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * Generated by scripts/gen-types.mjs from schema/protocol.schema.json.
4
+ * Do not edit directly; update the schema and run `pnpm gen`.
5
+ */
6
+ export {};
@@ -0,0 +1,124 @@
1
+ export type { HostedAdapterMetadata } from "./adapter-metadata.js";
2
+ export { assertAsyncQuestions, assertQuestionRequest, assertQuestionResponse, questionAnswerText } from "./questions.js";
3
+ export type { AsyncUserInputQuestion, AsyncQuestionReplySnapshot, QuestionRequest, QuestionResponse } from "./generated/protocol-types.js";
4
+ export { assertJsonByteLimit } from "./json-size.js";
5
+ export { INVOKE_REQUEST_MAX_BYTES, assertInvokeRequestSize } from "./invoke-size.js";
6
+ export * from "./stream-limits.js";
7
+ export { assertKernelStatus, assertServiceProcessSnapshot } from "./service-processes.js";
8
+ export * from "./run-protocol.js";
9
+ export type { KernelLookupKey, KernelRunRef, KernelRunSnapshot, KernelStatus, ServiceProcessSnapshot } from "./generated/protocol-types.js";
10
+ export * from "./invoke-input.js";
11
+ export * from "./model-context.js";
12
+ export * from "./execution-plan.js";
13
+ export { contextHash } from "./context-hash.js";
14
+ export { assertJsonValue } from "./context.js";
15
+ export type { ToolAuthorization, IssuedToolAuthorization } from "./generated/protocol-types.js";
16
+ export { PROVIDER_DIAGNOSTIC_MAX_BYTES } from "./experience.js";
17
+ export { IMAGE_INPUT_LIMITS, IMAGE_INPUT_MIME_TYPES, assertModelInputParts, providerInputParts, hasImageInput, modelPartsFromInput } from "./multimodal.js";
18
+ export { APPROVAL_MODES, CONTEXT_SCHEMA, CONTEXT_MAX_BYTES, CONTEXT_MAX_ITEMS, DEFAULT_RUN_TIMEOUT_MS, MAX_RUN_TIMEOUT_MS, RUNTIME_RUN_CONTRACT, assertAgentSource, assertApprovalMode, assertContextEnvelope, assertContextEnvs, assertMcpServers, assertContextMcp, assertResolvedExecutionPlan, canonicalContext, contextItem, mergeContext } from "./context.js";
19
+ export { RUNTIME_SELECTION_SCHEMA, assertResolvedRuntimeSelection } from "./runtime-selection.js";
20
+ export { CONTEXT_TYPE_CATALOG, contextTypeDefinition, findContextTypeDefinition } from "./context-catalog.js";
21
+ export type { ContextTypeDefinition } from "./context-catalog.js";
22
+ export { assertContextConfiguration, resolveContextConfiguration } from "./context-configuration.js";
23
+ export { assertNotificationMessage } from "./notification.js";
24
+ import type { ActivityStartedPayload, ActivityUpdatedPayload, ActivityFinishedPayload, PlanUpdatedPayload, ToolProgressPayload, RunNoticePayload, CanonicalEventPayload, ChannelContextAppend, ChannelContextDescriptor, ChannelMessageFact, ChannelScope, ContextSyncResult, InvokeRequestWire, RuntimeLimits, MessageChannel, MessageExposure, InteractionRequestedPayload, InteractionResolvedPayload, ModelStepFinishedPayload, ModelStepStartedPayload, ToolCallCreatePayload, ToolCallDeltaPayload, ToolCallUpdatePayload, FailureEnvelope } from "./generated/protocol-types.js";
25
+ export type { AgentSource, NotificationMessage, ModelInputPart, ApprovalMode, ApprovalRequest, ApprovalOperation, ApprovalDisplayDetails, ContextItem, ContextInlinePayload, ContextReferencesPayload, ContextInlineEntry, ContextReferenceEntry, ContextEnvelope, ContextConfiguration, ContextPreparationReceipt, RunContextProjection, ContextAdapterPayload, ContextModelPayload, ContextActmodePayload, ExecutionEvidence, ContextReasoningPayload, ContextWorkspacePayload, ContextLimitsPayload, ContextEnvsPayload, ContextRuntimeSelectionPayload, ContextApprovalPolicyPayload, ContextSelectionEntry, ContextResourceEntry, ContextInstructionEntry, ContextInstructionsPayload, ContextContinuityPayload, ResolvedExecutionPlan, ResolvedRuntimeSelection, MessageChannel, MessageExposure, MessageProvenance, ProviderSession, AgentConfig, RuntimeLimits, ActivityInfo, ActivitySubject, ActivityStartedPayload, ActivityUpdatedPayload, ActivityFinishedPayload, PlanUpdatedPayload, ToolProgressPayload, RunNoticePayload, CanonicalEventPayload, InteractionRequestedPayload, InteractionResolvedPayload, ModelStepStartedPayload, ModelStepFinishedPayload, ToolCallCreatePayload, ToolCallDeltaPayload, ToolCallUpdatePayload, FailureAction, FailureSource, FailureCause, FailureEnvelope, ChannelScope, ChannelMessagePart, ChannelMessageSender, ChannelMessageFlags, ChannelMessageFact, ChannelContextAppend, ContextSyncRequest, ContextSyncResult, ChannelContextDescriptor, ContextCommitResult, McpStdioServer, McpStreamableHttpServer, McpServer, McpServers, RunIdentity, InvokeRequestWire } from "./generated/protocol-types.js";
26
+ export { FAILURE_CATALOG, classifyFailure, isCodexLocalFailureReason, isCodexLocalFailure, failureMessage, failurePayload, isFailureEnvelope, type FailureClassificationContext, type FailureDomain, type PublicFailureCode } from "./failure.js";
27
+ import type { RunIdentity } from "./generated/protocol-types.js";
28
+ /**
29
+ * The three terminal states a Run may reach.
30
+ *
31
+ * `finished` means normal completion, `error` means execution failed, and
32
+ * `stopped` means an explicit cancellation or an aborted stream. The Adapter
33
+ * Host guarantees every invocation delivers exactly one of these upstream.
34
+ */
35
+ export declare const PROTOCOL_VERSION: 2;
36
+ export declare function canonicalTerminalStatus(value: unknown): "completed" | "failed" | "cancelled";
37
+ export declare const TERMINAL_EVENT_TYPES: readonly ["run.completed", "run.failed", "run.cancelled"];
38
+ export type TerminalEventType = (typeof TERMINAL_EVENT_TYPES)[number];
39
+ /**
40
+ * The stable event set the Core can persist and upper-layer UIs can consume.
41
+ *
42
+ * Rough lifecycle: Run queued/running -> message, tool, surface and usage
43
+ * updates -> a Run terminal. Provider-native event names must be translated
44
+ * inside the adapter and must never leak through to this level.
45
+ */
46
+ export { contextActmode, assertExecutionEvidence } from "./actmode.js";
47
+ export declare const CANONICAL_EVENT_TYPES: readonly ["session.update", "execution.update", "usage.update", "model_step.started", "model_step.finished", "message.create", "message.delta", "message.update", "tool_call.create", "tool_call.delta", "tool_call.update", "activity.started", "activity.updated", "activity.finished", "plan.updated", "tool_call.progress", "run.notice", "interaction.requested", "interaction.resolved", "run.queued", "run.started", "run.completed", "run.failed", "run.cancelled"];
48
+ /** canonical 模式下的统一事件类型;native-only Adapter 无须转换原生事件。 */
49
+ export type CanonicalEventType = (typeof CANONICAL_EVENT_TYPES)[number];
50
+ export type CanonicalPayloadFor<TType extends CanonicalEventType> = TType extends "activity.started" ? CanonicalEventPayload & ActivityStartedPayload : TType extends "activity.updated" ? CanonicalEventPayload & ActivityUpdatedPayload : TType extends "activity.finished" ? CanonicalEventPayload & ActivityFinishedPayload : TType extends "plan.updated" ? CanonicalEventPayload & PlanUpdatedPayload : TType extends "tool_call.progress" ? CanonicalEventPayload & ToolProgressPayload : TType extends "run.notice" ? CanonicalEventPayload & RunNoticePayload : TType extends "model_step.started" ? CanonicalEventPayload & ModelStepStartedPayload : TType extends "model_step.finished" ? CanonicalEventPayload & ModelStepFinishedPayload : TType extends "interaction.requested" ? CanonicalEventPayload & InteractionRequestedPayload : TType extends "interaction.resolved" ? CanonicalEventPayload & InteractionResolvedPayload : TType extends "tool_call.create" ? CanonicalEventPayload & ToolCallCreatePayload : TType extends "tool_call.delta" ? CanonicalEventPayload & ToolCallDeltaPayload : TType extends "tool_call.update" ? CanonicalEventPayload & ToolCallUpdatePayload : CanonicalEventPayload;
51
+ /** Adapter 在 canonical 模式下输出的最小事件单元;工具生命周期的 payload 随类型收窄。 */
52
+ export type CanonicalEvent<TType extends CanonicalEventType = CanonicalEventType> = TType extends CanonicalEventType ? {
53
+ protocolVersion: 2;
54
+ type: TType;
55
+ payload: CanonicalPayloadFor<TType>;
56
+ } : never;
57
+ /**
58
+ * A single execution request the Core sends to the Adapter Host.
59
+ *
60
+ * The serializable fields come from the generated {@link InvokeRequestWire};
61
+ * `signal` is a runtime object that cannot cross a process boundary, so it is
62
+ * mixed in here (for in-process calls only) rather than added to the schema.
63
+ */
64
+ export interface InvokeRequest extends InvokeRequestWire {
65
+ /** Fired when the Host cancels the invocation; the adapter should propagate it to the subprocess or a protocol cancel. */
66
+ signal?: AbortSignal;
67
+ }
68
+ export declare const INTERACTION_RESPONSE_OUTCOMES: readonly ["accepted", "declined", "answered", "cancelled"];
69
+ export type InteractionResponseOutcome = (typeof INTERACTION_RESPONSE_OUTCOMES)[number];
70
+ /** Opaque answer carrier routed back to the provider request that emitted an interaction. */
71
+ export interface InteractionResponse {
72
+ interactionId: string;
73
+ outcome: InteractionResponseOutcome;
74
+ value?: unknown;
75
+ }
76
+ /** Provider adapters must use this accessor so hidden context is sent exactly once when present. */
77
+ export declare function providerInputText(request: InvokeRequest): string;
78
+ /** Inject trusted instructions only when starting a provider session, including a fresh restart. */
79
+ export declare function initialControlInstructions(request: InvokeRequest, freshSession?: boolean): string;
80
+ /** Exact alternate input for a provider that could not resume its session. */
81
+ export declare function freshFallbackInputText(request: InvokeRequest): string;
82
+ /** Runtime validation at the Agent Work plugin boundary; JSON schema remains the wire source of truth. */
83
+ export declare function assertChannelScope(value: unknown): asserts value is ChannelScope;
84
+ export declare function assertChannelMessageFact(value: unknown): asserts value is ChannelMessageFact;
85
+ export declare function assertChannelContextAppend(value: unknown): asserts value is ChannelContextAppend;
86
+ export declare function assertContextSyncResult(value: unknown): asserts value is ContextSyncResult;
87
+ export declare function assertChannelContextDescriptor(value: unknown): asserts value is ChannelContextDescriptor;
88
+ /**
89
+ * The event record written to the Store.
90
+ * `seq` is monotonic only within a single run; consumers should order and
91
+ * dedupe on `(runId, seq)`.
92
+ */
93
+ export type EventEnvelope<TType extends CanonicalEventType = CanonicalEventType> = CanonicalEvent<TType> & {
94
+ /** A globally random ID for each persisted event. */
95
+ id: string;
96
+ seq: number;
97
+ tsMs: number;
98
+ agentSessionId: string;
99
+ runId: string;
100
+ };
101
+ export declare const TERMINAL_EVENTS: ReadonlySet<CanonicalEventType>;
102
+ export declare const EVENT_TYPES: ReadonlySet<CanonicalEventType>;
103
+ export declare const MESSAGE_EXPOSURES: ReadonlySet<MessageExposure>;
104
+ export declare const MESSAGE_CHANNELS: ReadonlySet<MessageChannel>;
105
+ /**
106
+ * Validate an adapter event and stamp it with the ID, sequence, timestamp and
107
+ * Run ownership that persistence requires. Returns a frozen object so callers
108
+ * cannot mutate it after append.
109
+ */
110
+ export declare function envelope<TType extends CanonicalEventType>(run: RunIdentity, seq: number, event: CanonicalEvent<TType>): Readonly<EventEnvelope<TType>>;
111
+ /** Assert the minimal runtime shape of a canonical event at the dynamic adapter boundary. */
112
+ export declare function assertCanonicalEvent(event: unknown): asserts event is CanonicalEvent;
113
+ export declare function assertApprovalRequest(value: unknown): asserts value is Record<string, unknown>;
114
+ /** Validate a response before it crosses the process or provider boundary. */
115
+ export declare function assertInteractionResponse(value: unknown): asserts value is InteractionResponse;
116
+ /** Validate a structured failure at the dynamic adapter boundary. */
117
+ export declare function assertFailureEnvelope(value: unknown): asserts value is FailureEnvelope;
118
+ /** Assert the execution identifiers and path fields that must be present before the Host calls an adapter. */
119
+ export declare function assertInvokeRequest(request: unknown): asserts request is InvokeRequest;
120
+ export declare function assertRuntimeLimits(value: unknown): asserts value is RuntimeLimits;
121
+ /** Type guard: whether an event ends the current Run. */
122
+ export declare function isTerminal(event: CanonicalEvent): event is CanonicalEvent<TerminalEventType>;
123
+ /** Missing or malformed analysis metadata is never treated as public. */
124
+ export declare function messageExposure(event: CanonicalEvent): MessageExposure;