@masons/agent-network 0.6.15 → 0.6.16

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 (41) hide show
  1. package/dist/_vendor/runtime-adapter-client/conformance.d.ts +8 -0
  2. package/dist/_vendor/runtime-adapter-client/conformance.d.ts.map +1 -0
  3. package/dist/_vendor/runtime-adapter-client/conformance.js +75 -0
  4. package/dist/_vendor/runtime-adapter-client/icm.d.ts +6 -0
  5. package/dist/_vendor/runtime-adapter-client/icm.d.ts.map +1 -0
  6. package/dist/_vendor/runtime-adapter-client/icm.js +86 -0
  7. package/dist/_vendor/runtime-adapter-client/index.d.ts +7 -0
  8. package/dist/_vendor/runtime-adapter-client/index.d.ts.map +1 -0
  9. package/dist/_vendor/runtime-adapter-client/index.js +6 -0
  10. package/dist/_vendor/runtime-adapter-client/runtime-adapter-api.d.ts +300 -0
  11. package/dist/_vendor/runtime-adapter-client/runtime-adapter-api.d.ts.map +1 -0
  12. package/dist/_vendor/runtime-adapter-client/runtime-adapter-api.js +3112 -0
  13. package/dist/_vendor/runtime-adapter-client/send-admission.d.ts +89 -0
  14. package/dist/_vendor/runtime-adapter-client/send-admission.d.ts.map +1 -0
  15. package/dist/_vendor/runtime-adapter-client/send-admission.js +169 -0
  16. package/dist/_vendor/runtime-adapter-client/types.d.ts +632 -0
  17. package/dist/_vendor/runtime-adapter-client/types.d.ts.map +1 -0
  18. package/dist/_vendor/runtime-adapter-client/types.js +33 -0
  19. package/dist/_vendor/runtime-adapter-client/work-target.d.ts +5 -0
  20. package/dist/_vendor/runtime-adapter-client/work-target.d.ts.map +1 -0
  21. package/dist/_vendor/runtime-adapter-client/work-target.js +47 -0
  22. package/dist/channel.d.ts.map +1 -1
  23. package/dist/channel.js +105 -29
  24. package/dist/connector-client.d.ts +2 -1
  25. package/dist/connector-client.d.ts.map +1 -1
  26. package/dist/connector-client.js +6 -1
  27. package/dist/plugin.d.ts +1 -1
  28. package/dist/plugin.d.ts.map +1 -1
  29. package/dist/plugin.js +15 -8
  30. package/dist/services-retained-recipient.d.ts +58 -0
  31. package/dist/services-retained-recipient.d.ts.map +1 -0
  32. package/dist/services-retained-recipient.js +324 -0
  33. package/dist/turn-context.d.ts +2 -0
  34. package/dist/turn-context.d.ts.map +1 -1
  35. package/dist/turn-context.js +9 -0
  36. package/dist/types.d.ts +5 -1
  37. package/dist/types.d.ts.map +1 -1
  38. package/dist/types.js +3 -0
  39. package/dist/version.d.ts +1 -1
  40. package/dist/version.js +1 -1
  41. package/package.json +3 -3
@@ -0,0 +1,89 @@
1
+ import type { RuntimeWorkTargetRef } from "./types.js";
2
+ export declare const SEND_ADMISSION_DECISIONS: readonly ["admit", "hold", "reject", "unknown"];
3
+ export type SendAdmissionDecision = (typeof SEND_ADMISSION_DECISIONS)[number];
4
+ export declare const SEND_ADMISSION_REASON_CODES: readonly ["admitted", "relationship_not_sendable", "policy_denied", "session_selection_required", "continuation_session_unavailable", "target_endpoint_unavailable", "missing_runtime_session_id", "runtime_work_target_unavailable", "capability_missing", "assignment_in_progress", "runtime_busy", "composer_read_only", "queued_recoverable", "setup_control_only", "message_loop_unproven", "receivability_unknown"];
5
+ export type SendAdmissionReasonCode = (typeof SEND_ADMISSION_REASON_CODES)[number];
6
+ export declare const SEND_ADMISSION_USER_ACTIONS: readonly ["none", "select_runtime_session", "wait", "refresh", "retry", "use_ordinary_node_conversation", "contact_owner_or_admin"];
7
+ export type SendAdmissionUserAction = (typeof SEND_ADMISSION_USER_ACTIONS)[number];
8
+ export type SendAdmissionActorKind = "owner" | "runtime_adapter" | "remote_node" | "system";
9
+ export type SendAdmissionMessageContextKind = "remote_first_contact" | "remote_continuation" | "runtime_mailbox_dispatch" | "owner_directed_runtime_session" | "runtime_adapter_claim";
10
+ export interface SendAdmissionRequest {
11
+ actor: {
12
+ kind: SendAdmissionActorKind;
13
+ principal_id?: string;
14
+ node_id?: string;
15
+ };
16
+ recipient: {
17
+ node_id: string;
18
+ };
19
+ caller_hints?: {
20
+ runtime_session_id?: string;
21
+ endpoint_id?: string;
22
+ runtime_work_target_ref?: RuntimeWorkTargetRef;
23
+ selected_by_owner?: boolean;
24
+ };
25
+ message_context: {
26
+ kind: SendAdmissionMessageContextKind;
27
+ source_message_id?: string;
28
+ origin_scid?: string;
29
+ origin_ncid?: string;
30
+ owner_session_message_id?: string;
31
+ };
32
+ }
33
+ export interface SendAdmissionReceiverPath {
34
+ kind: "runtime_pull" | "adapter_managed_turn" | "owner_session_delivery";
35
+ target_ref?: RuntimeWorkTargetRef;
36
+ runtime_session_identity_key?: string;
37
+ endpoint_id?: string;
38
+ }
39
+ export type SendAdmissionSourceFact = string | ({
40
+ kind: string;
41
+ } & Record<string, unknown>);
42
+ export interface SendAdmissionResponse {
43
+ decision: SendAdmissionDecision;
44
+ business_receivable_now: boolean;
45
+ reason_code: SendAdmissionReasonCode;
46
+ receiver_path?: SendAdmissionReceiverPath;
47
+ retryable: boolean;
48
+ user_action: SendAdmissionUserAction;
49
+ source_facts: SendAdmissionSourceFact[];
50
+ }
51
+ export declare const SEND_ADMISSION_FIXTURES: {
52
+ readonly admittedAdapterManagedTurn: {
53
+ readonly decision: "admit";
54
+ readonly business_receivable_now: true;
55
+ readonly reason_code: "admitted";
56
+ readonly receiver_path: {
57
+ readonly kind: "adapter_managed_turn";
58
+ readonly target_ref: {
59
+ readonly kind: "projection_endpoint";
60
+ readonly projection_endpoint_id: "ep1_codex";
61
+ readonly runtime_session_id: "thread_123";
62
+ readonly background_exchange_mode: "adapter_managed_turn";
63
+ };
64
+ readonly runtime_session_identity_key: "agent_1:codex:owner_1:a665a45920422f9d417e4867efdc4fb8";
65
+ readonly endpoint_id: "ep1_codex";
66
+ };
67
+ readonly retryable: false;
68
+ readonly user_action: "none";
69
+ readonly source_facts: ["services_derived_runtime_work_target"];
70
+ };
71
+ readonly holdSessionSelectionRequired: {
72
+ readonly decision: "hold";
73
+ readonly business_receivable_now: false;
74
+ readonly reason_code: "session_selection_required";
75
+ readonly retryable: true;
76
+ readonly user_action: "select_runtime_session";
77
+ readonly source_facts: ["multi_session_runtime_without_selected_session"];
78
+ };
79
+ readonly rejectSetupControlOnly: {
80
+ readonly decision: "reject";
81
+ readonly business_receivable_now: false;
82
+ readonly reason_code: "setup_control_only";
83
+ readonly retryable: false;
84
+ readonly user_action: "contact_owner_or_admin";
85
+ readonly source_facts: ["setup_reachable_without_business_receiver_path"];
86
+ };
87
+ };
88
+ export declare function parseSendAdmissionResponse(value: unknown): SendAdmissionResponse | null;
89
+ //# sourceMappingURL=send-admission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-admission.d.ts","sourceRoot":"","sources":["../../../src/_vendor/runtime-adapter-client/send-admission.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGvD,eAAO,MAAM,wBAAwB,iDAK3B,CAAC;AAEX,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9E,eAAO,MAAM,2BAA2B,2ZAiB9B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/C,eAAO,MAAM,2BAA2B,qIAQ9B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/C,MAAM,MAAM,sBAAsB,GAC9B,OAAO,GACP,iBAAiB,GACjB,aAAa,GACb,QAAQ,CAAC;AAEb,MAAM,MAAM,+BAA+B,GACvC,sBAAsB,GACtB,qBAAqB,GACrB,0BAA0B,GAC1B,gCAAgC,GAChC,uBAAuB,CAAC;AAE5B,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE;QACL,IAAI,EAAE,sBAAsB,CAAC;QAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,OAAO,CAAC,EAAE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AO,GACb,qBAAqB,GAAG,IAAI,CAiD9B"}
@@ -0,0 +1,169 @@
1
+ import { parseRuntimeWorkTargetRef } from "./work-target.js";
2
+ export const SEND_ADMISSION_DECISIONS = [
3
+ "admit",
4
+ "hold",
5
+ "reject",
6
+ "unknown",
7
+ ];
8
+ export const SEND_ADMISSION_REASON_CODES = [
9
+ "admitted",
10
+ "relationship_not_sendable",
11
+ "policy_denied",
12
+ "session_selection_required",
13
+ "continuation_session_unavailable",
14
+ "target_endpoint_unavailable",
15
+ "missing_runtime_session_id",
16
+ "runtime_work_target_unavailable",
17
+ "capability_missing",
18
+ "assignment_in_progress",
19
+ "runtime_busy",
20
+ "composer_read_only",
21
+ "queued_recoverable",
22
+ "setup_control_only",
23
+ "message_loop_unproven",
24
+ "receivability_unknown",
25
+ ];
26
+ export const SEND_ADMISSION_USER_ACTIONS = [
27
+ "none",
28
+ "select_runtime_session",
29
+ "wait",
30
+ "refresh",
31
+ "retry",
32
+ "use_ordinary_node_conversation",
33
+ "contact_owner_or_admin",
34
+ ];
35
+ export const SEND_ADMISSION_FIXTURES = {
36
+ admittedAdapterManagedTurn: {
37
+ decision: "admit",
38
+ business_receivable_now: true,
39
+ reason_code: "admitted",
40
+ receiver_path: {
41
+ kind: "adapter_managed_turn",
42
+ target_ref: {
43
+ kind: "projection_endpoint",
44
+ projection_endpoint_id: "ep1_codex",
45
+ runtime_session_id: "thread_123",
46
+ background_exchange_mode: "adapter_managed_turn",
47
+ },
48
+ runtime_session_identity_key: "agent_1:codex:owner_1:a665a45920422f9d417e4867efdc4fb8",
49
+ endpoint_id: "ep1_codex",
50
+ },
51
+ retryable: false,
52
+ user_action: "none",
53
+ source_facts: ["services_derived_runtime_work_target"],
54
+ },
55
+ holdSessionSelectionRequired: {
56
+ decision: "hold",
57
+ business_receivable_now: false,
58
+ reason_code: "session_selection_required",
59
+ retryable: true,
60
+ user_action: "select_runtime_session",
61
+ source_facts: ["multi_session_runtime_without_selected_session"],
62
+ },
63
+ rejectSetupControlOnly: {
64
+ decision: "reject",
65
+ business_receivable_now: false,
66
+ reason_code: "setup_control_only",
67
+ retryable: false,
68
+ user_action: "contact_owner_or_admin",
69
+ source_facts: ["setup_reachable_without_business_receiver_path"],
70
+ },
71
+ };
72
+ export function parseSendAdmissionResponse(value) {
73
+ if (!isRecord(value))
74
+ return null;
75
+ if (!includesLiteral(SEND_ADMISSION_DECISIONS, value.decision) ||
76
+ typeof value.business_receivable_now !== "boolean" ||
77
+ !includesLiteral(SEND_ADMISSION_REASON_CODES, value.reason_code) ||
78
+ typeof value.retryable !== "boolean" ||
79
+ !includesLiteral(SEND_ADMISSION_USER_ACTIONS, value.user_action) ||
80
+ !Array.isArray(value.source_facts)) {
81
+ return null;
82
+ }
83
+ const receiverPath = parseReceiverPath(value.receiver_path);
84
+ if (value.receiver_path !== undefined && receiverPath === null)
85
+ return null;
86
+ if (value.business_receivable_now &&
87
+ (value.decision !== "admit" || receiverPath === undefined)) {
88
+ return null;
89
+ }
90
+ if (value.decision === "admit" &&
91
+ (!value.business_receivable_now || receiverPath === undefined)) {
92
+ return null;
93
+ }
94
+ if (value.decision !== "admit" &&
95
+ (value.business_receivable_now || receiverPath !== undefined)) {
96
+ return null;
97
+ }
98
+ const admittedReceiverPath = receiverPath === null ? undefined : receiverPath;
99
+ const sourceFacts = parseSourceFacts(value.source_facts);
100
+ if (!sourceFacts)
101
+ return null;
102
+ return {
103
+ decision: value.decision,
104
+ business_receivable_now: value.business_receivable_now,
105
+ reason_code: value.reason_code,
106
+ ...(admittedReceiverPath !== undefined && {
107
+ receiver_path: admittedReceiverPath,
108
+ }),
109
+ retryable: value.retryable,
110
+ user_action: value.user_action,
111
+ source_facts: sourceFacts,
112
+ };
113
+ }
114
+ function parseReceiverPath(value) {
115
+ if (value === undefined)
116
+ return undefined;
117
+ if (!isRecord(value))
118
+ return null;
119
+ if (value.kind !== "runtime_pull" &&
120
+ value.kind !== "adapter_managed_turn" &&
121
+ value.kind !== "owner_session_delivery") {
122
+ return null;
123
+ }
124
+ const targetRef = value.target_ref === undefined
125
+ ? undefined
126
+ : parseRuntimeWorkTargetRef(value.target_ref);
127
+ if (value.target_ref !== undefined && targetRef === null)
128
+ return null;
129
+ if (value.runtime_session_identity_key !== undefined &&
130
+ typeof value.runtime_session_identity_key !== "string") {
131
+ return null;
132
+ }
133
+ if (value.endpoint_id !== undefined &&
134
+ typeof value.endpoint_id !== "string") {
135
+ return null;
136
+ }
137
+ const receiverTargetRef = targetRef === null ? undefined : targetRef;
138
+ return {
139
+ kind: value.kind,
140
+ ...(receiverTargetRef !== undefined && { target_ref: receiverTargetRef }),
141
+ ...(typeof value.runtime_session_identity_key === "string" && {
142
+ runtime_session_identity_key: value.runtime_session_identity_key,
143
+ }),
144
+ ...(typeof value.endpoint_id === "string" && {
145
+ endpoint_id: value.endpoint_id,
146
+ }),
147
+ };
148
+ }
149
+ function parseSourceFacts(value) {
150
+ const facts = [];
151
+ for (const item of value) {
152
+ if (typeof item === "string") {
153
+ facts.push(item);
154
+ continue;
155
+ }
156
+ if (isRecord(item) && typeof item.kind === "string") {
157
+ facts.push({ ...item, kind: item.kind });
158
+ continue;
159
+ }
160
+ return null;
161
+ }
162
+ return facts;
163
+ }
164
+ function includesLiteral(values, value) {
165
+ return typeof value === "string" && values.includes(value);
166
+ }
167
+ function isRecord(value) {
168
+ return typeof value === "object" && value !== null && !Array.isArray(value);
169
+ }