@opengeni/contracts 0.21.0 → 0.22.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/dist/index.d.ts +717 -190
- package/dist/index.js +148 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +184 -16
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -626,6 +626,81 @@ export const DEFAULT_FIRST_PARTY_MCP_PERMISSIONS = [
|
|
|
626
626
|
"github:use",
|
|
627
627
|
] as const satisfies readonly Permission[];
|
|
628
628
|
|
|
629
|
+
/**
|
|
630
|
+
* Exact public catalog for tools served by the broad first-party `opengeni`
|
|
631
|
+
* MCP server. Adding a registration does not make it model-visible: the name
|
|
632
|
+
* must be admitted here and selected by the session policy.
|
|
633
|
+
*
|
|
634
|
+
* `files_get_download_url` intentionally is not in this catalog. It belongs to
|
|
635
|
+
* the dedicated `files` MCP server.
|
|
636
|
+
*/
|
|
637
|
+
export const FIRST_PARTY_MCP_TOOL_NAMES = [
|
|
638
|
+
"set_session_title",
|
|
639
|
+
"goal_set",
|
|
640
|
+
"goal_update",
|
|
641
|
+
"goal_complete",
|
|
642
|
+
"goal_pause",
|
|
643
|
+
"memory_search",
|
|
644
|
+
"memory_save",
|
|
645
|
+
"memory_correct",
|
|
646
|
+
"sandboxes_list",
|
|
647
|
+
"sandbox_attach",
|
|
648
|
+
"sandbox_swap",
|
|
649
|
+
"run_on",
|
|
650
|
+
"sandbox_provision",
|
|
651
|
+
"rig_list",
|
|
652
|
+
"rig_get",
|
|
653
|
+
"rig_propose_change",
|
|
654
|
+
"rig_verify",
|
|
655
|
+
"rig_promote",
|
|
656
|
+
"sessions_list",
|
|
657
|
+
"session_get",
|
|
658
|
+
"session_events",
|
|
659
|
+
"session_create",
|
|
660
|
+
"session_send_message",
|
|
661
|
+
"session_pause",
|
|
662
|
+
"session_resume",
|
|
663
|
+
"session_steer",
|
|
664
|
+
"set_other_session_title",
|
|
665
|
+
"variable_set_list",
|
|
666
|
+
"environment_list",
|
|
667
|
+
"variable_set_set_variable",
|
|
668
|
+
"environment_set_variable",
|
|
669
|
+
"github_connect_link",
|
|
670
|
+
"github_token",
|
|
671
|
+
"github_repositories_list",
|
|
672
|
+
"social_connections_list",
|
|
673
|
+
"social_posts_recent",
|
|
674
|
+
"social_daily_analysis_context",
|
|
675
|
+
"scheduled_tasks_list",
|
|
676
|
+
"scheduled_tasks_get",
|
|
677
|
+
"scheduled_tasks_create",
|
|
678
|
+
"scheduled_tasks_update",
|
|
679
|
+
"scheduled_tasks_pause",
|
|
680
|
+
"scheduled_tasks_resume",
|
|
681
|
+
"scheduled_tasks_trigger",
|
|
682
|
+
"scheduled_tasks_delete",
|
|
683
|
+
"scheduled_task_runs_list",
|
|
684
|
+
"slack_bot_list_channels",
|
|
685
|
+
"slack_bot_channel_history",
|
|
686
|
+
"slack_bot_list_users",
|
|
687
|
+
"slack_bot_post_message",
|
|
688
|
+
] as const;
|
|
689
|
+
export const FirstPartyMcpToolName = z.enum(FIRST_PARTY_MCP_TOOL_NAMES);
|
|
690
|
+
export type FirstPartyMcpToolName = z.infer<typeof FirstPartyMcpToolName>;
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* Ordinary sessions get only the small self-management surface. Authorization
|
|
694
|
+
* permissions remain an independent, additional boundary.
|
|
695
|
+
*/
|
|
696
|
+
export const DEFAULT_FIRST_PARTY_MCP_TOOLS = [
|
|
697
|
+
"set_session_title",
|
|
698
|
+
"goal_set",
|
|
699
|
+
"goal_update",
|
|
700
|
+
"goal_complete",
|
|
701
|
+
"goal_pause",
|
|
702
|
+
] as const satisfies readonly FirstPartyMcpToolName[];
|
|
703
|
+
|
|
629
704
|
export function prefixedMcpToolName(registryId: string, toolName: string): string {
|
|
630
705
|
return `${registryId}__${toolName}`;
|
|
631
706
|
}
|
|
@@ -1139,6 +1214,9 @@ export const DelegatedAccessTokenPayload = z
|
|
|
1139
1214
|
// Worker-asserted session scope for first-party MCP calls (HMAC-signed, not
|
|
1140
1215
|
// agent-controlled); enables session-scoped tools such as goal management.
|
|
1141
1216
|
sessionId: z.string().uuid().optional(),
|
|
1217
|
+
// Model-visible first-party tool selection for a worker-bound session.
|
|
1218
|
+
// This is visibility only; permissions remain the authorization boundary.
|
|
1219
|
+
firstPartyMcpTools: z.array(FirstPartyMcpToolName).optional(),
|
|
1142
1220
|
// The turn making the call (the caller's identity), HMAC-signed by the worker
|
|
1143
1221
|
// at turn setup. Lets a tool classify WHO is calling from the token itself,
|
|
1144
1222
|
// instead of racily re-reading the session's live active_turn_id — e.g. the
|
|
@@ -3608,21 +3686,6 @@ export const ComposerDraft = z.object({
|
|
|
3608
3686
|
});
|
|
3609
3687
|
export type ComposerDraft = z.infer<typeof ComposerDraft>;
|
|
3610
3688
|
|
|
3611
|
-
export const SessionQueueSnapshot = z.object({
|
|
3612
|
-
version: z.number().int().nonnegative(),
|
|
3613
|
-
effectiveControl: EffectiveSessionControl,
|
|
3614
|
-
/**
|
|
3615
|
-
* True while the latest attempt is interrupted but has not durably proved
|
|
3616
|
-
* quiescence: no more inference, user-visible output, or workspace-persistence
|
|
3617
|
-
* authority. Temporal cancellation/terminalization is not that proof. This is
|
|
3618
|
-
* distinct from ordinary capacity queueing, remains accurate with an empty
|
|
3619
|
-
* visible queue, and is independent of Steer-row metadata or withdrawal.
|
|
3620
|
-
*/
|
|
3621
|
-
stoppingPreviousAttempt: z.boolean(),
|
|
3622
|
-
items: z.array(SessionTurn),
|
|
3623
|
-
});
|
|
3624
|
-
export type SessionQueueSnapshot = z.infer<typeof SessionQueueSnapshot>;
|
|
3625
|
-
|
|
3626
3689
|
export const MoveSessionQueueItemRequest = z.object({
|
|
3627
3690
|
clientEventId: SessionOperationKey,
|
|
3628
3691
|
expectedQueueVersion: z.number().int().nonnegative(),
|
|
@@ -3974,7 +4037,6 @@ export type SessionSystemUpdatePayload = z.infer<typeof SessionSystemUpdatePaylo
|
|
|
3974
4037
|
|
|
3975
4038
|
export const SessionSystemUpdateState = z.enum([
|
|
3976
4039
|
"pending",
|
|
3977
|
-
"deferred",
|
|
3978
4040
|
"delivered",
|
|
3979
4041
|
"cancelled",
|
|
3980
4042
|
"superseded",
|
|
@@ -3994,11 +4056,104 @@ export const SessionSystemUpdate = z.object({
|
|
|
3994
4056
|
lineage: z.record(z.string(), z.unknown()),
|
|
3995
4057
|
state: SessionSystemUpdateState,
|
|
3996
4058
|
deliveredTurnId: z.string().uuid().nullable(),
|
|
4059
|
+
/**
|
|
4060
|
+
* The exact durable model-memory row containing the coalesced batch that
|
|
4061
|
+
* delivered this update. Null until claim; every member of one batch shares
|
|
4062
|
+
* the same id.
|
|
4063
|
+
*/
|
|
4064
|
+
deliveredHistoryItemId: z.string().uuid().nullable(),
|
|
3997
4065
|
deliveredAt: z.string().nullable(),
|
|
3998
4066
|
createdAt: z.string(),
|
|
3999
4067
|
});
|
|
4000
4068
|
export type SessionSystemUpdate = z.infer<typeof SessionSystemUpdate>;
|
|
4001
4069
|
|
|
4070
|
+
/**
|
|
4071
|
+
* Bounded queue projection of a canonical pending machine input. Full payload,
|
|
4072
|
+
* lineage, and dedupe data remain in canonical storage and never inflate the
|
|
4073
|
+
* hot queue response.
|
|
4074
|
+
*/
|
|
4075
|
+
export const SessionPendingInputPreview = SessionSystemUpdate.pick({
|
|
4076
|
+
id: true,
|
|
4077
|
+
sessionId: true,
|
|
4078
|
+
kind: true,
|
|
4079
|
+
classification: true,
|
|
4080
|
+
sourceId: true,
|
|
4081
|
+
summary: true,
|
|
4082
|
+
createdAt: true,
|
|
4083
|
+
});
|
|
4084
|
+
export type SessionPendingInputPreview = z.infer<typeof SessionPendingInputPreview>;
|
|
4085
|
+
|
|
4086
|
+
export const SessionQueueSnapshot = z.object({
|
|
4087
|
+
version: z.number().int().nonnegative(),
|
|
4088
|
+
effectiveControl: EffectiveSessionControl,
|
|
4089
|
+
/**
|
|
4090
|
+
* True while the latest attempt is interrupted but has not durably proved
|
|
4091
|
+
* quiescence: no more inference, user-visible output, or workspace-persistence
|
|
4092
|
+
* authority. Temporal cancellation/terminalization is not that proof. This is
|
|
4093
|
+
* distinct from ordinary capacity queueing, remains accurate with an empty
|
|
4094
|
+
* visible queue, and is independent of Steer-row metadata or withdrawal.
|
|
4095
|
+
*/
|
|
4096
|
+
stoppingPreviousAttempt: z.boolean(),
|
|
4097
|
+
items: z.array(SessionTurn),
|
|
4098
|
+
/** Canonical bounded previews; never reconstructed from session events. */
|
|
4099
|
+
pendingInputs: z.array(SessionPendingInputPreview),
|
|
4100
|
+
/**
|
|
4101
|
+
* Exact members of the next bounded machine-input batch that will join an
|
|
4102
|
+
* already-waiting human/API prompt. Null means the next machine-input claim
|
|
4103
|
+
* is standalone. This is a projection of canonical rows, not queue state.
|
|
4104
|
+
*/
|
|
4105
|
+
pendingInputAttachment: z
|
|
4106
|
+
.object({
|
|
4107
|
+
turnId: z.string().uuid(),
|
|
4108
|
+
inputIds: z.array(z.string().uuid()).min(1),
|
|
4109
|
+
})
|
|
4110
|
+
.nullable(),
|
|
4111
|
+
});
|
|
4112
|
+
export type SessionQueueSnapshot = z.infer<typeof SessionQueueSnapshot>;
|
|
4113
|
+
|
|
4114
|
+
/**
|
|
4115
|
+
* Deterministic, protocol-safe model representation of one claimed machine
|
|
4116
|
+
* input batch. This exact string is persisted before inference and replayed on
|
|
4117
|
+
* every later turn; callers must not synthesize an equivalent transient copy.
|
|
4118
|
+
*/
|
|
4119
|
+
export function renderSessionSystemUpdateBatch(
|
|
4120
|
+
updates: ReadonlyArray<
|
|
4121
|
+
Pick<
|
|
4122
|
+
SessionSystemUpdate,
|
|
4123
|
+
"id" | "kind" | "classification" | "sourceId" | "summary" | "payload" | "lineage"
|
|
4124
|
+
>
|
|
4125
|
+
>,
|
|
4126
|
+
): string {
|
|
4127
|
+
if (updates.length === 0) {
|
|
4128
|
+
throw new TypeError("A durable machine-input batch requires at least one update");
|
|
4129
|
+
}
|
|
4130
|
+
return [
|
|
4131
|
+
"[OpenGeni internal updates]",
|
|
4132
|
+
"These platform updates were delivered together for this inference. They are not human prompts.",
|
|
4133
|
+
JSON.stringify({
|
|
4134
|
+
updates: updates.map((update) => ({
|
|
4135
|
+
id: update.id,
|
|
4136
|
+
kind: update.kind,
|
|
4137
|
+
classification: update.classification,
|
|
4138
|
+
sourceId: update.sourceId,
|
|
4139
|
+
summary: update.summary,
|
|
4140
|
+
payload: update.payload,
|
|
4141
|
+
lineage: update.lineage,
|
|
4142
|
+
})),
|
|
4143
|
+
}),
|
|
4144
|
+
].join("\n");
|
|
4145
|
+
}
|
|
4146
|
+
|
|
4147
|
+
export function sessionSystemUpdateBatchHistoryItem(
|
|
4148
|
+
updates: Parameters<typeof renderSessionSystemUpdateBatch>[0],
|
|
4149
|
+
): { type: "message"; role: "system"; content: string } {
|
|
4150
|
+
return {
|
|
4151
|
+
type: "message",
|
|
4152
|
+
role: "system",
|
|
4153
|
+
content: renderSessionSystemUpdateBatch(updates),
|
|
4154
|
+
};
|
|
4155
|
+
}
|
|
4156
|
+
|
|
4002
4157
|
export const VariableSetVariableName = z
|
|
4003
4158
|
.string()
|
|
4004
4159
|
.regex(/^[A-Z][A-Z0-9_]*$/)
|
|
@@ -5092,6 +5247,9 @@ export const Session = z.object({
|
|
|
5092
5247
|
// Non-default first-party MCP token permissions (manager-style sessions);
|
|
5093
5248
|
// null means the fixed worker default set.
|
|
5094
5249
|
firstPartyMcpPermissions: z.array(Permission).nullable(),
|
|
5250
|
+
// null means the fixed minimal worker-visible default. An explicit array,
|
|
5251
|
+
// including [], is the exact model-visible first-party selection.
|
|
5252
|
+
firstPartyMcpTools: z.array(FirstPartyMcpToolName).nullable().default(null),
|
|
5095
5253
|
// Per-session third-party MCP servers, metadata only. Credential values are
|
|
5096
5254
|
// write-only and never appear here.
|
|
5097
5255
|
mcpServers: z.array(SessionMcpServerMetadata).default([]),
|
|
@@ -5264,6 +5422,9 @@ export const SessionEventType = z.enum([
|
|
|
5264
5422
|
"goal.continuation",
|
|
5265
5423
|
"system.update.pending",
|
|
5266
5424
|
"system.update.delivered",
|
|
5425
|
+
"system.update.superseded",
|
|
5426
|
+
"system.update.cancelled",
|
|
5427
|
+
"system.update.settled",
|
|
5267
5428
|
"session.control.paused",
|
|
5268
5429
|
"session.control.resumed",
|
|
5269
5430
|
"session.control.steer_requested",
|
|
@@ -5464,6 +5625,9 @@ export const SESSION_EVENT_SEMANTIC_CLASS_TYPES = {
|
|
|
5464
5625
|
"goal.continuation",
|
|
5465
5626
|
"system.update.pending",
|
|
5466
5627
|
"system.update.delivered",
|
|
5628
|
+
"system.update.superseded",
|
|
5629
|
+
"system.update.cancelled",
|
|
5630
|
+
"system.update.settled",
|
|
5467
5631
|
"session.control.paused",
|
|
5468
5632
|
"session.control.resumed",
|
|
5469
5633
|
"session.control.steer_requested",
|
|
@@ -7377,6 +7541,10 @@ export const CreateSessionRequest = withVariableSetIdAlias({
|
|
|
7377
7541
|
// A goal-bearing session whose explicit/effective set omits goals:manage is
|
|
7378
7542
|
// rejected; creation never silently expands a child beyond that set.
|
|
7379
7543
|
firstPartyMcpPermissions: z.array(Permission).optional(),
|
|
7544
|
+
// Exact model-visible selection from the broad first-party OpenGeni MCP
|
|
7545
|
+
// catalog. Omit for the minimal default; [] intentionally exposes none.
|
|
7546
|
+
// This does not grant authority: every registered tool is permission-gated.
|
|
7547
|
+
firstPartyMcpTools: z.array(FirstPartyMcpToolName).optional(),
|
|
7380
7548
|
// Third-party MCP servers attached only to this session. For an agent-created
|
|
7381
7549
|
// child, omission snapshots its trusted immediate parent's server definitions,
|
|
7382
7550
|
// policies, connection refs, and encrypted credentials. Explicit arrays,
|