@vercel/factory 0.0.17 → 0.0.19
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/CHANGELOG.md +52 -0
- package/dist/api-contracts.d.mts +665 -715
- package/dist/api-contracts.mjs +91 -4
- package/dist/api-contracts.mjs.map +1 -1
- package/dist/api-task-graph.mjs +14 -5
- package/dist/api-task-graph.mjs.map +1 -1
- package/dist/api.d.mts +58 -11
- package/dist/api.mjs +715 -399
- package/dist/api.mjs.map +1 -1
- package/dist/approval-access.d.mts +1 -1
- package/dist/approval-contracts.d.mts +3 -4
- package/dist/approval-contracts.mjs +1 -2
- package/dist/approval-contracts.mjs.map +1 -1
- package/dist/blob/index.d.mts +1 -1
- package/dist/budget.mjs +20 -3
- package/dist/budget.mjs.map +1 -1
- package/dist/change-verification/brief.d.mts +1 -1
- package/dist/change-verification/dispatch.mjs +8 -1
- package/dist/change-verification/dispatch.mjs.map +1 -1
- package/dist/changes/eve-record-change.mjs +4 -1
- package/dist/changes/eve-record-change.mjs.map +1 -1
- package/dist/client-stream.d.mts +19 -2
- package/dist/client-stream.mjs +115 -53
- package/dist/client-stream.mjs.map +1 -1
- package/dist/client-transcript.d.mts +25 -2
- package/dist/client-transcript.mjs +95 -13
- package/dist/client-transcript.mjs.map +1 -1
- package/dist/client.d.mts +145 -19
- package/dist/client.mjs +89 -16
- package/dist/client.mjs.map +1 -1
- package/dist/code-review/contracts.d.mts +1 -0
- package/dist/code-review/eve-post-review.d.mts +4 -2
- package/dist/code-review/eve-post-review.mjs +8 -0
- package/dist/code-review/eve-post-review.mjs.map +1 -1
- package/dist/code-review/github-reporter.d.mts +6 -2
- package/dist/code-review/github-reporter.mjs +86 -35
- package/dist/code-review/github-reporter.mjs.map +1 -1
- package/dist/code-review/preparation.d.mts +2 -1
- package/dist/code-review/preparation.mjs +2 -1
- package/dist/code-review/preparation.mjs.map +1 -1
- package/dist/code-review/stall.mjs +11 -2
- package/dist/code-review/stall.mjs.map +1 -1
- package/dist/connectors/github.d.mts +1 -1
- package/dist/connectors/index.d.mts +1 -1
- package/dist/connectors/slack.d.mts +1 -1
- package/dist/delivery-metrics/metrics.d.mts +1 -1
- package/dist/dispatch.mjs +3 -3
- package/dist/dispatch.mjs.map +1 -1
- package/dist/eve/index.d.mts +1 -1
- package/dist/eve/index.mjs +8 -1
- package/dist/eve/index.mjs.map +1 -1
- package/dist/eve/task-execution.d.mts +4 -4
- package/dist/eve/transcript.d.mts +3 -1
- package/dist/eve/transcript.mjs.map +1 -1
- package/dist/finding-remediation/admission.d.mts +1 -1
- package/dist/finding-remediation/brief.d.mts +1 -1
- package/dist/github-app.d.mts +1 -1
- package/dist/github-publication.d.mts +1 -1
- package/dist/github.d.mts +9 -1
- package/dist/github.mjs +29 -11
- package/dist/github.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/intake-contracts.d.mts +1 -0
- package/dist/intake-contracts.mjs +2 -1
- package/dist/intake-contracts.mjs.map +1 -1
- package/dist/integrations/github-issues.d.mts +64 -0
- package/dist/integrations/github-issues.mjs +175 -0
- package/dist/integrations/github-issues.mjs.map +1 -0
- package/dist/integrations/github.d.mts +2 -1
- package/dist/integrations/github.mjs +2 -1
- package/dist/multi-repository-changes/coordination.mjs +1 -1
- package/dist/planning/reconcile.mjs +15 -2
- package/dist/planning/reconcile.mjs.map +1 -1
- package/dist/postgres/index.d.mts +2 -1
- package/dist/postgres/index.mjs +11 -5
- package/dist/postgres/index.mjs.map +1 -1
- package/dist/postgres/indexed-codec.mjs +137 -0
- package/dist/postgres/indexed-codec.mjs.map +1 -0
- package/dist/postgres/indexed-schema.mjs +99 -0
- package/dist/postgres/indexed-schema.mjs.map +1 -0
- package/dist/postgres/indexed.d.mts +28 -0
- package/dist/postgres/indexed.mjs +277 -0
- package/dist/postgres/indexed.mjs.map +1 -0
- package/dist/postgres/record-predicates.mjs +23 -0
- package/dist/postgres/record-predicates.mjs.map +1 -0
- package/dist/presets/software-development/deepsec-brief.d.mts +1 -1
- package/dist/presets/software-development/dispatch.mjs +1 -1
- package/dist/presets/software-development/dispatch.mjs.map +1 -1
- package/dist/presets/software-development/recovery.mjs +9 -2
- package/dist/presets/software-development/recovery.mjs.map +1 -1
- package/dist/pull-requests/eve-fetch.d.mts +4 -1
- package/dist/pull-requests/eve-fetch.mjs +9 -0
- package/dist/pull-requests/eve-fetch.mjs.map +1 -1
- package/dist/pull-requests/github-publisher.d.mts +1 -1
- package/dist/pull-requests/github-publisher.mjs +19 -7
- package/dist/pull-requests/github-publisher.mjs.map +1 -1
- package/dist/repositories.mjs +20 -13
- package/dist/repositories.mjs.map +1 -1
- package/dist/sandbox/execution-run-ledger.d.mts +2 -2
- package/dist/sandbox/execution-run-ledger.mjs.map +1 -1
- package/dist/sandbox/execution.d.mts +2 -2
- package/dist/sandbox/execution.mjs.map +1 -1
- package/dist/schema/catalog.mjs +1 -1
- package/dist/schema/change.d.mts +1 -1
- package/dist/schema/communication.d.mts +2 -2
- package/dist/schema/factory-config.d.mts +1 -1
- package/dist/schema/outbox.d.mts +6 -6
- package/dist/schema/session-summary.d.mts +218 -0
- package/dist/schema/session-summary.mjs +68 -0
- package/dist/schema/session-summary.mjs.map +1 -0
- package/dist/schema/session.d.mts +39 -59
- package/dist/schema/session.mjs +6 -6
- package/dist/schema/session.mjs.map +1 -1
- package/dist/schema/task-graph.d.mts +24 -24
- package/dist/schema/transcript.d.mts +141 -3
- package/dist/schema/transcript.mjs +19 -3
- package/dist/schema/transcript.mjs.map +1 -1
- package/dist/schema/transitions.d.mts +1 -1
- package/dist/schema/transitions.mjs +1 -1
- package/dist/schema/transitions.mjs.map +1 -1
- package/dist/signals.d.mts +1 -1
- package/dist/stall.mjs +10 -2
- package/dist/stall.mjs.map +1 -1
- package/dist/storage.d.mts +10 -1
- package/dist/storage.mjs +7 -1
- package/dist/store/approvals.d.mts +14 -0
- package/dist/store/approvals.mjs +78 -0
- package/dist/store/approvals.mjs.map +1 -0
- package/dist/store/conversations.d.mts +59 -0
- package/dist/store/conversations.mjs +549 -0
- package/dist/store/conversations.mjs.map +1 -0
- package/dist/store/driver.d.mts +1 -1
- package/dist/store/driver.mjs.map +1 -1
- package/dist/store/engine.d.mts +38 -16
- package/dist/store/engine.mjs +229 -106
- package/dist/store/engine.mjs.map +1 -1
- package/dist/store/indexed-engine.d.mts +57 -0
- package/dist/store/indexed-engine.mjs +155 -0
- package/dist/store/indexed-engine.mjs.map +1 -0
- package/dist/store/indexed-memory.d.mts +7 -0
- package/dist/store/indexed-memory.mjs +200 -0
- package/dist/store/indexed-memory.mjs.map +1 -0
- package/dist/store/indexed-projections.d.mts +280 -0
- package/dist/store/indexed-projections.mjs +481 -0
- package/dist/store/indexed-projections.mjs.map +1 -0
- package/dist/store/indexed.d.mts +101 -0
- package/dist/store/indexed.mjs +19 -0
- package/dist/store/indexed.mjs.map +1 -0
- package/dist/store/iterate.d.mts +9 -0
- package/dist/store/iterate.mjs +23 -0
- package/dist/store/iterate.mjs.map +1 -0
- package/dist/store/query-scope.mjs +62 -0
- package/dist/store/query-scope.mjs.map +1 -0
- package/dist/store/query.d.mts +32 -0
- package/dist/store/query.mjs +103 -0
- package/dist/store/query.mjs.map +1 -0
- package/dist/store/session-history.mjs +24 -0
- package/dist/store/session-history.mjs.map +1 -0
- package/dist/store/slack-pr-notifications.d.mts +2 -2
- package/dist/store/slack-pr-notifications.mjs.map +1 -1
- package/dist/store/state.d.mts +26 -0
- package/dist/store/state.mjs +95 -0
- package/dist/store/state.mjs.map +1 -0
- package/dist/store/task-effects.d.mts +1 -1
- package/dist/store/task-graphs.d.mts +1 -1
- package/dist/store/task-messages.d.mts +1 -1
- package/dist/store/task-work.d.mts +1 -1
- package/dist/store/task-work.mjs +1 -1
- package/dist/store/transcripts.mjs +308 -0
- package/dist/store/transcripts.mjs.map +1 -0
- package/dist/sweep.d.mts +1 -1
- package/dist/sweep.mjs +12 -7
- package/dist/sweep.mjs.map +1 -1
- package/dist/task-communication.mjs +15 -1
- package/dist/task-communication.mjs.map +1 -1
- package/dist/task-protocols.d.mts +3 -3
- package/dist/tasks.d.mts +1 -1
- package/dist/vercel.d.mts +1 -1
- package/dist/work-triage/find-existing-work.d.mts +1 -1
- package/dist/work-triage/find-existing-work.mjs +12 -2
- package/dist/work-triage/find-existing-work.mjs.map +1 -1
- package/docs/index.md +4 -0
- package/docs/recipes/persistence-recovery.md +15 -9
- package/docs/recipes/postgres-indexed-engine.md +108 -0
- package/docs/recipes/postgres-indexed-storage.md +145 -0
- package/package.json +3 -1
package/dist/api-contracts.mjs
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { changeIdSchema, repositoryIdSchema, taskIdSchema } from "./schema/id.mjs";
|
|
2
2
|
import { repositorySlugSchema } from "./schema/repository.mjs";
|
|
3
3
|
import { agentRouteBindingSchema } from "./schema/agent-route.mjs";
|
|
4
|
-
import { executionReferenceSchema, taskSchema } from "./schema/task.mjs";
|
|
4
|
+
import { executionReferenceSchema, taskSchema, taskStateSchema } from "./schema/task.mjs";
|
|
5
5
|
import { hasMessageContent, imageAttachmentsSchema } from "./image-input.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { findingSchema } from "./schema/finding.mjs";
|
|
7
|
+
import { changeStateSchema } from "./schema/change.mjs";
|
|
8
|
+
import { agentSessionIdSchema, agentSessionMessageSchema, agentSessionSchema, sessionContinuationSchema } from "./schema/session.mjs";
|
|
9
|
+
import { communicationEventSchema } from "./schema/communication.mjs";
|
|
10
|
+
import { conversationStatusSchema, conversationSummarySchema } from "./schema/session-summary.mjs";
|
|
7
11
|
import { z } from "zod";
|
|
8
12
|
//#region src/api-contracts.ts
|
|
9
13
|
/** Validates an agent exposed by the operator API. */
|
|
@@ -59,15 +63,96 @@ const answerSessionQuestionRequestSchema = z.strictObject({
|
|
|
59
63
|
questionId: taskIdSchema.describe("Question Task belonging to this operator session."),
|
|
60
64
|
answer: z.string().min(1).max(16e3).describe("Authenticated immutable human answer.")
|
|
61
65
|
});
|
|
66
|
+
/** Validates an operator conversation card with read-only finding metadata for approval work. */
|
|
67
|
+
const sessionSummarySchema = conversationSummarySchema.extend({ finding: findingSchema.pick({
|
|
68
|
+
priority: true,
|
|
69
|
+
category: true
|
|
70
|
+
}).nullable().optional().describe("Finding metadata resolved at read time for approval work; never persisted on the card.") });
|
|
71
|
+
/** Validates the provider lifecycle reported for a pull request linked to a conversation. */
|
|
72
|
+
const sessionPullRequestStateSchema = z.enum([
|
|
73
|
+
"draft",
|
|
74
|
+
"open",
|
|
75
|
+
"merged",
|
|
76
|
+
"closed"
|
|
77
|
+
]);
|
|
78
|
+
/** Validates one current pull-request status resolved from authorized conversation work. */
|
|
79
|
+
const sessionPullRequestSchema = z.strictObject({
|
|
80
|
+
changeId: changeIdSchema.describe("Canonical Change represented by this pull request."),
|
|
81
|
+
repositoryId: repositoryIdSchema.describe("Configured repository containing the pull request."),
|
|
82
|
+
repository: repositorySlugSchema.describe("Display slug of the configured repository."),
|
|
83
|
+
number: z.number().int().positive().describe("Provider-owned pull-request number."),
|
|
84
|
+
url: z.url().describe("Provider URL for the pull request."),
|
|
85
|
+
state: sessionPullRequestStateSchema.nullable().describe("Current provider lifecycle, or null when no current observation is available."),
|
|
86
|
+
changeState: changeStateSchema.describe("Current durable Factory Change lifecycle."),
|
|
87
|
+
verification: z.enum([
|
|
88
|
+
"pending",
|
|
89
|
+
"passed",
|
|
90
|
+
"unknown"
|
|
91
|
+
]).describe("Factory verification state, kept separate from provider review state."),
|
|
92
|
+
reviewReadiness: z.enum([
|
|
93
|
+
"draft",
|
|
94
|
+
"not_ready",
|
|
95
|
+
"ready",
|
|
96
|
+
"complete",
|
|
97
|
+
"closed",
|
|
98
|
+
"unknown"
|
|
99
|
+
]).describe("Factory handoff readiness without implying provider approval or mergeability."),
|
|
100
|
+
sync: z.enum([
|
|
101
|
+
"fresh",
|
|
102
|
+
"stale",
|
|
103
|
+
"unavailable"
|
|
104
|
+
]).describe("Freshness of the provider status observation."),
|
|
105
|
+
observedAt: z.iso.datetime().optional().describe("Time the displayed provider state was last confirmed."),
|
|
106
|
+
checkedAt: z.iso.datetime().describe("Time the provider status was last checked or attempted."),
|
|
107
|
+
syncMessage: z.string().max(500).optional().describe("Safe explanation when current provider status could not be confirmed.")
|
|
108
|
+
});
|
|
109
|
+
/** Validates one concise delegated-task row in an operator conversation. */
|
|
110
|
+
const sessionWorkTaskSchema = z.strictObject({
|
|
111
|
+
taskId: taskIdSchema.describe("Exact Task available in the work inspector."),
|
|
112
|
+
title: z.string().min(1).max(256).describe("Operator-facing Task title."),
|
|
113
|
+
agent: z.string().min(1).max(64).describe("Application agent assigned to this Task."),
|
|
114
|
+
state: taskStateSchema.describe("Current durable Task lifecycle."),
|
|
115
|
+
attempt: z.number().int().positive().describe("Current Task attempt.")
|
|
116
|
+
});
|
|
117
|
+
/** Validates the single final result presented for one completed conversation request. */
|
|
118
|
+
const sessionWorkResultSchema = z.strictObject({
|
|
119
|
+
summary: z.string().trim().min(1).max(4e3).describe("Readable description of the completed work."),
|
|
120
|
+
verification: z.enum([
|
|
121
|
+
"passed",
|
|
122
|
+
"failed",
|
|
123
|
+
"not_required",
|
|
124
|
+
"unknown"
|
|
125
|
+
]).describe("Independent verification outcome, separate from pull-request lifecycle."),
|
|
126
|
+
remainingAction: z.string().trim().min(1).max(1e3).optional().describe("Concrete human action still required after completion, when any.")
|
|
127
|
+
});
|
|
128
|
+
/** Validates delegated progress and its optional final result, grouped by root request identity. */
|
|
129
|
+
const sessionWorkGroupSchema = z.strictObject({
|
|
130
|
+
requestId: taskIdSchema.describe("Root Task identity used to group retries and child work."),
|
|
131
|
+
title: z.string().min(1).max(256).describe("Operator-facing root request title."),
|
|
132
|
+
agent: z.string().min(1).max(64).describe("Application agent assigned to the root request."),
|
|
133
|
+
state: taskStateSchema.describe("Aggregate durable state of the grouped request."),
|
|
134
|
+
tasks: z.array(sessionWorkTaskSchema).min(1).readonly().describe("Authorized Tasks belonging to this request."),
|
|
135
|
+
changeIds: z.array(changeIdSchema).readonly().default([]).describe("Changes produced by Tasks in this request."),
|
|
136
|
+
result: sessionWorkResultSchema.optional().describe("One final result, present only after required work reaches a terminal state.")
|
|
137
|
+
});
|
|
62
138
|
/** Validates the current operator-facing projection of a Factory session. */
|
|
63
139
|
const sessionViewSchema = z.strictObject({
|
|
64
140
|
session: agentSessionSchema.describe("Durable interaction binding."),
|
|
141
|
+
continuation: sessionContinuationSchema.transform(({ context: _context, contextAttachments: _attachments, ...value }) => value).nullable().default(null).describe("Current follow-up request, without cached execution context."),
|
|
142
|
+
notifications: z.array(communicationEventSchema).readonly().default([]).describe("This page of delivered conversation notifications."),
|
|
143
|
+
notificationsNextCursor: z.string().nullable().default(null).describe("Continuation for older notifications."),
|
|
65
144
|
task: taskSchema.nullable().describe("Current task state, if workflow-backed."),
|
|
145
|
+
finding: findingSchema.nullable().optional().describe("Validated originating finding within the authorized Task and session repository scope."),
|
|
66
146
|
dependencyTaskIds: z.array(taskIdSchema).readonly().optional().describe("Read-only current Task dependencies projected from its authoritative task graph."),
|
|
67
147
|
execution: executionReferenceSchema.nullable().describe("Current execution; may change after recovery."),
|
|
68
148
|
activeAgent: z.string().optional().describe("Agent executing the selected work in this conversation."),
|
|
149
|
+
status: conversationStatusSchema.optional().describe("Current conversation-wide work and human-action status."),
|
|
150
|
+
statusRevision: z.string().length(64).optional().describe("Opaque revision for status-relevant conversation work."),
|
|
69
151
|
source: z.string().optional().describe("Original trigger of automatically started work."),
|
|
70
152
|
prUrl: z.string().optional().describe("Pull request associated with the conversation."),
|
|
153
|
+
pullRequests: z.array(sessionPullRequestSchema).readonly().default([]).describe("Current pull requests associated with authorized work in this conversation."),
|
|
154
|
+
pullRequestsTruncated: z.boolean().default(false).describe("Whether association discovery reached its configured work or result bound."),
|
|
155
|
+
workGroups: z.array(sessionWorkGroupSchema).readonly().default([]).describe("Delegated work grouped by request identity, with at most one final result per request."),
|
|
71
156
|
attention: z.enum([
|
|
72
157
|
"question",
|
|
73
158
|
"failed",
|
|
@@ -78,6 +163,8 @@ const sessionViewSchema = z.strictObject({
|
|
|
78
163
|
canFollowUp: z.boolean().optional().describe("Whether completed work can start a budgeted discussion in this conversation."),
|
|
79
164
|
hasWorkflowFailure: z.boolean().optional().describe("Whether delegated workflow work has failed, independently of a pending question."),
|
|
80
165
|
canCancel: z.boolean().optional().describe("Whether cancellation is available for the conversation or its delegated workflow work."),
|
|
166
|
+
historyNextCursor: z.string().nullable().optional().describe("Continuation for earlier execution history."),
|
|
167
|
+
relatedTasksNextCursor: z.string().nullable().optional().describe("Continuation for additional related work."),
|
|
81
168
|
history: z.array(z.strictObject({
|
|
82
169
|
taskId: taskIdSchema.optional().describe("Task owning this execution, if any."),
|
|
83
170
|
agent: z.string().describe("Agent that owns the provider execution."),
|
|
@@ -90,7 +177,7 @@ const sessionViewSchema = z.strictObject({
|
|
|
90
177
|
});
|
|
91
178
|
/** Validates a cursor-paginated page of operator-facing sessions. */
|
|
92
179
|
const sessionPageSchema = z.strictObject({
|
|
93
|
-
sessions: z.array(
|
|
180
|
+
sessions: z.array(sessionSummarySchema).readonly().describe("Sessions in this page."),
|
|
94
181
|
nextCursor: z.string().min(1).nullable().default(null).describe("Opaque cursor to pass unchanged for the next page, or null after the final page."),
|
|
95
182
|
totalCount: z.number().int().nonnegative().optional().describe("Total matching sessions when explicitly requested.")
|
|
96
183
|
});
|
|
@@ -114,6 +201,6 @@ const pendingFollowUpSchema = z.strictObject({
|
|
|
114
201
|
turnPolicy: z.enum(["steer", "queue"]).describe("Requested turn policy.")
|
|
115
202
|
}).refine(hasMessageContent, "Enter a message or attach an image");
|
|
116
203
|
//#endregion
|
|
117
|
-
export { answerSessionQuestionRequestSchema, apiAgentSchema, controlSessionRequestSchema, createSessionRequestSchema, pendingFollowUpSchema, repositoryDetailsSchema, repositorySummarySchema, sendSessionMessageRequestSchema, sessionInputResponseSchema, sessionPageSchema, sessionViewSchema, submitSessionInputRequestSchema };
|
|
204
|
+
export { answerSessionQuestionRequestSchema, apiAgentSchema, controlSessionRequestSchema, createSessionRequestSchema, pendingFollowUpSchema, repositoryDetailsSchema, repositorySummarySchema, sendSessionMessageRequestSchema, sessionInputResponseSchema, sessionPageSchema, sessionPullRequestSchema, sessionPullRequestStateSchema, sessionSummarySchema, sessionViewSchema, sessionWorkGroupSchema, sessionWorkResultSchema, sessionWorkTaskSchema, submitSessionInputRequestSchema };
|
|
118
205
|
|
|
119
206
|
//# sourceMappingURL=api-contracts.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-contracts.mjs","names":[],"sources":["../src/api-contracts.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { hasMessageContent, imageAttachmentsSchema, type ImageAttachment } from \"./image-input\";\nimport {\n changeIdSchema,\n repositoryIdSchema,\n taskIdSchema,\n type ChangeId,\n type TaskId,\n} from \"./schema/id\";\nimport { repositorySlugSchema, type RepositorySlug } from \"./schema/repository\";\nimport {\n agentRouteBindingSchema,\n type AgentRouteBinding,\n type AgentRouteBindingInput,\n} from \"./schema/agent-route\";\nimport {\n agentSessionIdSchema,\n agentSessionMessageSchema,\n agentSessionSchema,\n} from \"./schema/session\";\nimport { taskSchema, executionReferenceSchema } from \"./schema/task\";\n\n/** Validates an agent exposed by the operator API. */\nexport const apiAgentSchema = z.strictObject({\n id: z\n .string()\n .regex(/^[a-z][a-z0-9-]{0,31}$/u)\n .describe(\"Agent name used for discovery, filtering, and session creation when allowed.\"),\n description: z.string().describe(\"What this agent does.\"),\n route: agentRouteBindingSchema\n .optional()\n .describe(\"Exact registered specialist route; absent for conversations.\"),\n canStart: z\n .boolean()\n .describe(\"Whether an operator may start this agent directly through the session API.\"),\n requiresRepository: z.boolean().describe(\"Whether creation requires a configured repository.\"),\n requiresChange: z.boolean().describe(\"Whether creation requires an existing change ID.\"),\n});\n/** An agent exposed for operator discovery, filtering, or session creation. */\nexport type ApiAgent = Readonly<\n Omit<z.infer<typeof apiAgentSchema>, \"route\"> & {\n readonly route?: AgentRouteBinding;\n }\n>;\n\n/** Caller input for exposing an agent through the operator API before validation and branding. */\nexport interface ApiAgentInput {\n readonly id: string;\n readonly description: string;\n readonly route?: AgentRouteBindingInput;\n readonly canStart: boolean;\n readonly requiresRepository: boolean;\n readonly requiresChange: boolean;\n}\n\n/** Validates an idempotent request to create an operator session. */\nexport const createSessionRequestSchema = z\n .strictObject({\n operationId: z\n .string()\n .trim()\n .min(1)\n .max(200)\n .describe(\"Client-generated idempotency key; retain when retrying creation.\"),\n agent: apiAgentSchema.shape.id,\n model: z\n .string()\n .trim()\n .min(1)\n .max(200)\n .optional()\n .describe(\"Explicit supported model; absent uses the repository or application default.\"),\n repository: repositorySlugSchema.optional().describe(\"Configured owner/repo slug.\"),\n changeId: changeIdSchema.optional().describe(\"Existing change to review, verify, or continue.\"),\n message: agentSessionMessageSchema,\n attachments: imageAttachmentsSchema\n .optional()\n .describe(\"Uploaded images accompanying this message.\"),\n })\n .refine(hasMessageContent, \"Enter a message or attach an image\");\n/** An idempotent request to create an operator session. */\nexport type CreateSessionRequest = Readonly<\n Omit<z.input<typeof createSessionRequestSchema>, \"attachments\" | \"repository\" | \"changeId\">\n> & {\n readonly repository?: RepositorySlug;\n readonly changeId?: ChangeId;\n readonly attachments?: readonly ImageAttachment[];\n};\n\n/** Validates a message sent to an existing session with optimistic execution matching. */\nexport const sendSessionMessageRequestSchema = z\n .strictObject({\n message: agentSessionMessageSchema,\n attachments: imageAttachmentsSchema\n .optional()\n .describe(\"Uploaded images accompanying this message.\"),\n operationId: z\n .string()\n .trim()\n .min(1)\n .max(200)\n .optional()\n .describe(\"Required for a follow-up after completion; retain unchanged for retries.\"),\n turnPolicy: z\n .enum([\"steer\", \"queue\"])\n .default(\"steer\")\n .describe(\"Whether an active turn is steered immediately or the message is queued.\"),\n executionId: z\n .string()\n .min(1)\n .nullable()\n .describe(\"Observed execution ID; stale writes are rejected.\"),\n })\n .refine(hasMessageContent, \"Enter a message or attach an image\");\n\n/** Message sent to an existing session with optimistic execution matching. */\nexport type SendSessionMessageRequest = Readonly<\n Omit<z.input<typeof sendSessionMessageRequestSchema>, \"attachments\">\n> & {\n readonly attachments?: readonly ImageAttachment[];\n};\n\nconst sessionInputResponseBase = {\n requestId: z.string().min(1).describe(\"Pending provider input request ID.\"),\n};\n\n/** Validates an option selection or freeform answer to one provider input request. */\nexport const sessionInputResponseSchema = z.union([\n z.strictObject({\n ...sessionInputResponseBase,\n optionId: z.string().min(1).describe(\"Selected option ID.\"),\n text: z.never().optional().describe(\"Absent for an option selection.\"),\n }),\n z.strictObject({\n ...sessionInputResponseBase,\n optionId: z.never().optional().describe(\"Absent for a freeform answer.\"),\n text: z.string().min(1).describe(\"Freeform answer text.\"),\n }),\n]);\n/** A response to one pending provider input request. */\nexport type SessionInputResponse = Readonly<z.input<typeof sessionInputResponseSchema>>;\n\n/** Validates responses submitted to pending provider input requests. */\nexport const submitSessionInputRequestSchema = z.strictObject({\n executionId: z\n .string()\n .min(1)\n .describe(\"Observed provider session ID; stale input responses are rejected.\"),\n inputResponses: z\n .array(sessionInputResponseSchema)\n .min(1)\n .readonly()\n .describe(\"Responses to pending human-input requests.\"),\n});\n/** Responses submitted to pending provider input requests. */\nexport interface SubmitSessionInputRequest {\n readonly executionId: string;\n readonly inputResponses: readonly SessionInputResponse[];\n}\n\n/** Validates an execution-aware session control request. */\nexport const controlSessionRequestSchema = z.strictObject({\n executionId: z\n .string()\n .min(1)\n .optional()\n .describe(\"Observed provider session ID; guards against a replaced execution.\"),\n turnId: z.string().min(1).optional().describe(\"Observed turn ID for cooperative interruption.\"),\n});\n/** Execution and turn observed before requesting a session control operation. */\nexport type ControlSessionRequest = Readonly<z.input<typeof controlSessionRequestSchema>>;\n\n/** Validates an authenticated answer to a workflow question. */\nexport const answerSessionQuestionRequestSchema = z.strictObject({\n questionId: taskIdSchema.describe(\"Question Task belonging to this operator session.\"),\n answer: z.string().min(1).max(16000).describe(\"Authenticated immutable human answer.\"),\n});\n/** Authenticated answer to a workflow question in a session. */\nexport interface AnswerSessionQuestionRequest {\n readonly questionId: TaskId;\n readonly answer: string;\n}\n\n/** Validates the current operator-facing projection of a Factory session. */\nexport const sessionViewSchema = z.strictObject({\n session: agentSessionSchema.describe(\"Durable interaction binding.\"),\n task: taskSchema.nullable().describe(\"Current task state, if workflow-backed.\"),\n dependencyTaskIds: z\n .array(taskIdSchema)\n .readonly()\n .optional()\n .describe(\"Read-only current Task dependencies projected from its authoritative task graph.\"),\n execution: executionReferenceSchema\n .nullable()\n .describe(\"Current execution; may change after recovery.\"),\n activeAgent: z\n .string()\n .optional()\n .describe(\"Agent executing the selected work in this conversation.\"),\n source: z.string().optional().describe(\"Original trigger of automatically started work.\"),\n prUrl: z.string().optional().describe(\"Pull request associated with the conversation.\"),\n attention: z\n .enum([\"question\", \"failed\", \"stalled\", \"review\", \"conversation\"])\n .optional()\n .describe(\n \"Current human action: answer a question, inspect failed or stalled work, review a ready Change, or continue an external conversation.\",\n ),\n canFollowUp: z\n .boolean()\n .optional()\n .describe(\"Whether completed work can start a budgeted discussion in this conversation.\"),\n hasWorkflowFailure: z\n .boolean()\n .optional()\n .describe(\"Whether delegated workflow work has failed, independently of a pending question.\"),\n canCancel: z\n .boolean()\n .optional()\n .describe(\n \"Whether cancellation is available for the conversation or its delegated workflow work.\",\n ),\n history: z\n .array(\n z.strictObject({\n taskId: taskIdSchema.optional().describe(\"Task owning this execution, if any.\"),\n agent: z.string().describe(\"Agent that owns the provider execution.\"),\n message: z.string().describe(\"Initial request displayed for this execution.\"),\n attachments: imageAttachmentsSchema\n .optional()\n .describe(\"Images accompanying this execution's initial user request.\"),\n execution: executionReferenceSchema.describe(\"Authorized provider execution to replay.\"),\n }),\n )\n .readonly()\n .optional()\n .describe(\"Earlier executions, in conversation order, including replacement attempts.\"),\n relatedTasks: z\n .array(taskSchema)\n .readonly()\n .optional()\n .describe(\"Work linked to this conversation, including specialist delegations.\"),\n question: taskSchema\n .nullable()\n .describe(\"Open Factory question requiring an authenticated answer.\"),\n});\n/** The current operator-facing projection of a Factory session. */\nexport type SessionView = z.infer<typeof sessionViewSchema>;\n\n/** Validates a cursor-paginated page of operator-facing sessions. */\nexport const sessionPageSchema = z.strictObject({\n sessions: z.array(sessionViewSchema).readonly().describe(\"Sessions in this page.\"),\n nextCursor: z\n .string()\n .min(1)\n .nullable()\n .default(null)\n .describe(\"Opaque cursor to pass unchanged for the next page, or null after the final page.\"),\n totalCount: z\n .number()\n .int()\n .nonnegative()\n .optional()\n .describe(\"Total matching sessions when explicitly requested.\"),\n});\n/** Cursor-paginated operator-facing sessions. */\nexport type SessionPage = z.infer<typeof sessionPageSchema>;\n\n/** Validates one configured repository exposed by the operator API. */\nexport const repositorySummarySchema = z.strictObject({\n id: repositoryIdSchema.describe(\"Stable configured repository identifier.\"),\n slug: repositorySlugSchema.describe(\"Configured owner/repository slug.\"),\n});\n/** Configured repository exposed by the operator API. */\nexport type RepositorySummary = z.infer<typeof repositorySummarySchema>;\n\n/** Validates repository slugs and their stable identifiers. */\nexport const repositoryDetailsSchema = z.strictObject({\n repositories: z\n .array(repositorySlugSchema)\n .readonly()\n .describe(\"Configured owner/repository slugs.\"),\n details: z\n .array(repositorySummarySchema)\n .readonly()\n .default([])\n .describe(\"Stable identifiers and slugs for configured repositories.\"),\n});\n/** Repository slugs and their stable configured identifiers. */\nexport type RepositoryDetails = z.infer<typeof repositoryDetailsSchema>;\n\n/** Validates a locally retained follow-up awaiting confirmed API acceptance. */\nexport const pendingFollowUpSchema = z\n .strictObject({\n sessionId: agentSessionIdSchema.describe(\"Conversation containing this follow-up.\"),\n operationId: z\n .string()\n .min(1)\n .max(200)\n .describe(\"Stable operation id retained until acceptance is confirmed.\"),\n executionId: z\n .string()\n .nullable()\n .describe(\"Execution observed before sending, or null before execution starts.\"),\n message: agentSessionMessageSchema,\n attachments: imageAttachmentsSchema\n .optional()\n .describe(\"Uploaded images accompanying this message.\"),\n turnPolicy: z.enum([\"steer\", \"queue\"]).describe(\"Requested turn policy.\"),\n })\n .refine(hasMessageContent, \"Enter a message or attach an image\");\n/** A locally retained follow-up awaiting confirmed API acceptance. */\nexport type PendingFollowUp = Readonly<\n Omit<z.output<typeof pendingFollowUpSchema>, \"attachments\">\n> & {\n readonly attachments?: readonly ImageAttachment[];\n};\n"],"mappings":";;;;;;;;;AAuBA,MAAa,iBAAiB,EAAE,aAAa;CAC3C,IAAI,EACD,OAAO,CAAC,CACR,MAAM,yBAAyB,CAAC,CAChC,SAAS,8EAA8E;CAC1F,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS,uBAAuB;CACxD,OAAO,wBACJ,SAAS,CAAC,CACV,SAAS,8DAA8D;CAC1E,UAAU,EACP,QAAQ,CAAC,CACT,SAAS,4EAA4E;CACxF,oBAAoB,EAAE,QAAQ,CAAC,CAAC,SAAS,oDAAoD;CAC7F,gBAAgB,EAAE,QAAQ,CAAC,CAAC,SAAS,kDAAkD;AACzF,CAAC;;AAmBD,MAAa,6BAA6B,EACvC,aAAa;CACZ,aAAa,EACV,OAAO,CAAC,CACR,KAAK,CAAC,CACN,IAAI,CAAC,CAAC,CACN,IAAI,GAAG,CAAC,CACR,SAAS,kEAAkE;CAC9E,OAAO,eAAe,MAAM;CAC5B,OAAO,EACJ,OAAO,CAAC,CACR,KAAK,CAAC,CACN,IAAI,CAAC,CAAC,CACN,IAAI,GAAG,CAAC,CACR,SAAS,CAAC,CACV,SAAS,8EAA8E;CAC1F,YAAY,qBAAqB,SAAS,CAAC,CAAC,SAAS,6BAA6B;CAClF,UAAU,eAAe,SAAS,CAAC,CAAC,SAAS,iDAAiD;CAC9F,SAAS;CACT,aAAa,uBACV,SAAS,CAAC,CACV,SAAS,4CAA4C;AAC1D,CAAC,CAAC,CACD,OAAO,mBAAmB,oCAAoC;;AAWjE,MAAa,kCAAkC,EAC5C,aAAa;CACZ,SAAS;CACT,aAAa,uBACV,SAAS,CAAC,CACV,SAAS,4CAA4C;CACxD,aAAa,EACV,OAAO,CAAC,CACR,KAAK,CAA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ACxD,YAAY,EAAE,KAAK,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,SAAS,wBAAwB;AAC1E,CAAC,CAAC,CACD,OAAO,mBAAmB,oCAAoC"}
|
|
1
|
+
{"version":3,"file":"api-contracts.mjs","names":[],"sources":["../src/api-contracts.ts"],"sourcesContent":["import { conversationStatusSchema, conversationSummarySchema } from \"./schema/session-summary\";\nimport { findingSchema } from \"./schema/finding\";\nimport { z } from \"zod\";\nimport { hasMessageContent, imageAttachmentsSchema, type ImageAttachment } from \"./image-input\";\nimport {\n changeIdSchema,\n repositoryIdSchema,\n taskIdSchema,\n type ChangeId,\n type TaskId,\n} from \"./schema/id\";\nimport { repositorySlugSchema, type RepositorySlug } from \"./schema/repository\";\nimport {\n agentRouteBindingSchema,\n type AgentRouteBinding,\n type AgentRouteBindingInput,\n} from \"./schema/agent-route\";\nimport {\n agentSessionIdSchema,\n agentSessionMessageSchema,\n agentSessionSchema,\n sessionContinuationSchema,\n} from \"./schema/session\";\nimport { changeStateSchema } from \"./schema/change\";\nimport { communicationEventSchema } from \"./schema/communication\";\nimport { taskSchema, taskStateSchema, executionReferenceSchema } from \"./schema/task\";\n\n/** Validates an agent exposed by the operator API. */\nexport const apiAgentSchema = z.strictObject({\n id: z\n .string()\n .regex(/^[a-z][a-z0-9-]{0,31}$/u)\n .describe(\"Agent name used for discovery, filtering, and session creation when allowed.\"),\n description: z.string().describe(\"What this agent does.\"),\n route: agentRouteBindingSchema\n .optional()\n .describe(\"Exact registered specialist route; absent for conversations.\"),\n canStart: z\n .boolean()\n .describe(\"Whether an operator may start this agent directly through the session API.\"),\n requiresRepository: z.boolean().describe(\"Whether creation requires a configured repository.\"),\n requiresChange: z.boolean().describe(\"Whether creation requires an existing change ID.\"),\n});\n/** An agent exposed for operator discovery, filtering, or session creation. */\nexport type ApiAgent = Readonly<\n Omit<z.infer<typeof apiAgentSchema>, \"route\"> & {\n readonly route?: AgentRouteBinding;\n }\n>;\n\n/** Caller input for exposing an agent through the operator API before validation and branding. */\nexport interface ApiAgentInput {\n readonly id: string;\n readonly description: string;\n readonly route?: AgentRouteBindingInput;\n readonly canStart: boolean;\n readonly requiresRepository: boolean;\n readonly requiresChange: boolean;\n}\n\n/** Validates an idempotent request to create an operator session. */\nexport const createSessionRequestSchema = z\n .strictObject({\n operationId: z\n .string()\n .trim()\n .min(1)\n .max(200)\n .describe(\"Client-generated idempotency key; retain when retrying creation.\"),\n agent: apiAgentSchema.shape.id,\n model: z\n .string()\n .trim()\n .min(1)\n .max(200)\n .optional()\n .describe(\"Explicit supported model; absent uses the repository or application default.\"),\n repository: repositorySlugSchema.optional().describe(\"Configured owner/repo slug.\"),\n changeId: changeIdSchema.optional().describe(\"Existing change to review, verify, or continue.\"),\n message: agentSessionMessageSchema,\n attachments: imageAttachmentsSchema\n .optional()\n .describe(\"Uploaded images accompanying this message.\"),\n })\n .refine(hasMessageContent, \"Enter a message or attach an image\");\n/** An idempotent request to create an operator session. */\nexport type CreateSessionRequest = Readonly<\n Omit<z.input<typeof createSessionRequestSchema>, \"attachments\" | \"repository\" | \"changeId\">\n> & {\n readonly repository?: RepositorySlug;\n readonly changeId?: ChangeId;\n readonly attachments?: readonly ImageAttachment[];\n};\n\n/** Validates a message sent to an existing session with optimistic execution matching. */\nexport const sendSessionMessageRequestSchema = z\n .strictObject({\n message: agentSessionMessageSchema,\n attachments: imageAttachmentsSchema\n .optional()\n .describe(\"Uploaded images accompanying this message.\"),\n operationId: z\n .string()\n .trim()\n .min(1)\n .max(200)\n .optional()\n .describe(\"Required for a follow-up after completion; retain unchanged for retries.\"),\n turnPolicy: z\n .enum([\"steer\", \"queue\"])\n .default(\"steer\")\n .describe(\"Whether an active turn is steered immediately or the message is queued.\"),\n executionId: z\n .string()\n .min(1)\n .nullable()\n .describe(\"Observed execution ID; stale writes are rejected.\"),\n })\n .refine(hasMessageContent, \"Enter a message or attach an image\");\n\n/** Message sent to an existing session with optimistic execution matching. */\nexport type SendSessionMessageRequest = Readonly<\n Omit<z.input<typeof sendSessionMessageRequestSchema>, \"attachments\">\n> & {\n readonly attachments?: readonly ImageAttachment[];\n};\n\nconst sessionInputResponseBase = {\n requestId: z.string().min(1).describe(\"Pending provider input request ID.\"),\n};\n\n/** Validates an option selection or freeform answer to one provider input request. */\nexport const sessionInputResponseSchema = z.union([\n z.strictObject({\n ...sessionInputResponseBase,\n optionId: z.string().min(1).describe(\"Selected option ID.\"),\n text: z.never().optional().describe(\"Absent for an option selection.\"),\n }),\n z.strictObject({\n ...sessionInputResponseBase,\n optionId: z.never().optional().describe(\"Absent for a freeform answer.\"),\n text: z.string().min(1).describe(\"Freeform answer text.\"),\n }),\n]);\n/** A response to one pending provider input request. */\nexport type SessionInputResponse = Readonly<z.input<typeof sessionInputResponseSchema>>;\n\n/** Validates responses submitted to pending provider input requests. */\nexport const submitSessionInputRequestSchema = z.strictObject({\n executionId: z\n .string()\n .min(1)\n .describe(\"Observed provider session ID; stale input responses are rejected.\"),\n inputResponses: z\n .array(sessionInputResponseSchema)\n .min(1)\n .readonly()\n .describe(\"Responses to pending human-input requests.\"),\n});\n/** Responses submitted to pending provider input requests. */\nexport interface SubmitSessionInputRequest {\n readonly executionId: string;\n readonly inputResponses: readonly SessionInputResponse[];\n}\n\n/** Validates an execution-aware session control request. */\nexport const controlSessionRequestSchema = z.strictObject({\n executionId: z\n .string()\n .min(1)\n .optional()\n .describe(\"Observed provider session ID; guards against a replaced execution.\"),\n turnId: z.string().min(1).optional().describe(\"Observed turn ID for cooperative interruption.\"),\n});\n/** Execution and turn observed before requesting a session control operation. */\nexport type ControlSessionRequest = Readonly<z.input<typeof controlSessionRequestSchema>>;\n\n/** Validates an authenticated answer to a workflow question. */\nexport const answerSessionQuestionRequestSchema = z.strictObject({\n questionId: taskIdSchema.describe(\"Question Task belonging to this operator session.\"),\n answer: z.string().min(1).max(16000).describe(\"Authenticated immutable human answer.\"),\n});\n/** Authenticated answer to a workflow question in a session. */\nexport interface AnswerSessionQuestionRequest {\n readonly questionId: TaskId;\n readonly answer: string;\n}\n\n/** Validates an operator conversation card with read-only finding metadata for approval work. */\nexport const sessionSummarySchema = conversationSummarySchema.extend({\n finding: findingSchema\n .pick({ priority: true, category: true })\n .nullable()\n .optional()\n .describe(\n \"Finding metadata resolved at read time for approval work; never persisted on the card.\",\n ),\n});\n/** Compact operator conversation card; full finding evidence is available on SessionView. */\nexport type SessionSummary = z.infer<typeof sessionSummarySchema>;\n\n/** Validates the provider lifecycle reported for a pull request linked to a conversation. */\nexport const sessionPullRequestStateSchema = z.enum([\"draft\", \"open\", \"merged\", \"closed\"]);\n\n/** Validates one current pull-request status resolved from authorized conversation work. */\nexport const sessionPullRequestSchema = z.strictObject({\n changeId: changeIdSchema.describe(\"Canonical Change represented by this pull request.\"),\n repositoryId: repositoryIdSchema.describe(\"Configured repository containing the pull request.\"),\n repository: repositorySlugSchema.describe(\"Display slug of the configured repository.\"),\n number: z.number().int().positive().describe(\"Provider-owned pull-request number.\"),\n url: z.url().describe(\"Provider URL for the pull request.\"),\n state: sessionPullRequestStateSchema\n .nullable()\n .describe(\"Current provider lifecycle, or null when no current observation is available.\"),\n changeState: changeStateSchema.describe(\"Current durable Factory Change lifecycle.\"),\n verification: z\n .enum([\"pending\", \"passed\", \"unknown\"])\n .describe(\"Factory verification state, kept separate from provider review state.\"),\n reviewReadiness: z\n .enum([\"draft\", \"not_ready\", \"ready\", \"complete\", \"closed\", \"unknown\"])\n .describe(\"Factory handoff readiness without implying provider approval or mergeability.\"),\n sync: z\n .enum([\"fresh\", \"stale\", \"unavailable\"])\n .describe(\"Freshness of the provider status observation.\"),\n observedAt: z.iso\n .datetime()\n .optional()\n .describe(\"Time the displayed provider state was last confirmed.\"),\n checkedAt: z.iso.datetime().describe(\"Time the provider status was last checked or attempted.\"),\n syncMessage: z\n .string()\n .max(500)\n .optional()\n .describe(\"Safe explanation when current provider status could not be confirmed.\"),\n});\n/** Current provider and Factory lifecycle of a pull request linked to a conversation. */\nexport type SessionPullRequest = z.infer<typeof sessionPullRequestSchema>;\n\n/** Validates one concise delegated-task row in an operator conversation. */\nexport const sessionWorkTaskSchema = z.strictObject({\n taskId: taskIdSchema.describe(\"Exact Task available in the work inspector.\"),\n title: z.string().min(1).max(256).describe(\"Operator-facing Task title.\"),\n agent: z.string().min(1).max(64).describe(\"Application agent assigned to this Task.\"),\n state: taskStateSchema.describe(\"Current durable Task lifecycle.\"),\n attempt: z.number().int().positive().describe(\"Current Task attempt.\"),\n});\n/** Concise delegated-task progress shown inside a conversation work group. */\nexport type SessionWorkTask = z.infer<typeof sessionWorkTaskSchema>;\n\n/** Validates the single final result presented for one completed conversation request. */\nexport const sessionWorkResultSchema = z.strictObject({\n summary: z\n .string()\n .trim()\n .min(1)\n .max(4000)\n .describe(\"Readable description of the completed work.\"),\n verification: z\n .enum([\"passed\", \"failed\", \"not_required\", \"unknown\"])\n .describe(\"Independent verification outcome, separate from pull-request lifecycle.\"),\n remainingAction: z\n .string()\n .trim()\n .min(1)\n .max(1000)\n .optional()\n .describe(\"Concrete human action still required after completion, when any.\"),\n});\n/** One application-presented final result derived from validated workflow completion. */\nexport type SessionWorkResult = z.infer<typeof sessionWorkResultSchema>;\n\n/** Validates delegated progress and its optional final result, grouped by root request identity. */\nexport const sessionWorkGroupSchema = z.strictObject({\n requestId: taskIdSchema.describe(\"Root Task identity used to group retries and child work.\"),\n title: z.string().min(1).max(256).describe(\"Operator-facing root request title.\"),\n agent: z.string().min(1).max(64).describe(\"Application agent assigned to the root request.\"),\n state: taskStateSchema.describe(\"Aggregate durable state of the grouped request.\"),\n tasks: z\n .array(sessionWorkTaskSchema)\n .min(1)\n .readonly()\n .describe(\"Authorized Tasks belonging to this request.\"),\n changeIds: z\n .array(changeIdSchema)\n .readonly()\n .default([])\n .describe(\"Changes produced by Tasks in this request.\"),\n result: sessionWorkResultSchema\n .optional()\n .describe(\"One final result, present only after required work reaches a terminal state.\"),\n});\n/** Delegated conversation work grouped by its stable root request identity. */\nexport type SessionWorkGroup = z.infer<typeof sessionWorkGroupSchema>;\n\n/** Validates the current operator-facing projection of a Factory session. */\nexport const sessionViewSchema = z.strictObject({\n session: agentSessionSchema.describe(\"Durable interaction binding.\"),\n continuation: sessionContinuationSchema\n .transform(({ context: _context, contextAttachments: _attachments, ...value }) => value)\n .nullable()\n .default(null)\n .describe(\"Current follow-up request, without cached execution context.\"),\n notifications: z\n .array(communicationEventSchema)\n .readonly()\n .default([])\n .describe(\"This page of delivered conversation notifications.\"),\n notificationsNextCursor: z\n .string()\n .nullable()\n .default(null)\n .describe(\"Continuation for older notifications.\"),\n task: taskSchema.nullable().describe(\"Current task state, if workflow-backed.\"),\n finding: findingSchema\n .nullable()\n .optional()\n .describe(\n \"Validated originating finding within the authorized Task and session repository scope.\",\n ),\n dependencyTaskIds: z\n .array(taskIdSchema)\n .readonly()\n .optional()\n .describe(\"Read-only current Task dependencies projected from its authoritative task graph.\"),\n execution: executionReferenceSchema\n .nullable()\n .describe(\"Current execution; may change after recovery.\"),\n activeAgent: z\n .string()\n .optional()\n .describe(\"Agent executing the selected work in this conversation.\"),\n status: conversationStatusSchema\n .optional()\n .describe(\"Current conversation-wide work and human-action status.\"),\n statusRevision: z\n .string()\n .length(64)\n .optional()\n .describe(\"Opaque revision for status-relevant conversation work.\"),\n source: z.string().optional().describe(\"Original trigger of automatically started work.\"),\n prUrl: z.string().optional().describe(\"Pull request associated with the conversation.\"),\n pullRequests: z\n .array(sessionPullRequestSchema)\n .readonly()\n .default([])\n .describe(\"Current pull requests associated with authorized work in this conversation.\"),\n pullRequestsTruncated: z\n .boolean()\n .default(false)\n .describe(\"Whether association discovery reached its configured work or result bound.\"),\n workGroups: z\n .array(sessionWorkGroupSchema)\n .readonly()\n .default([])\n .describe(\n \"Delegated work grouped by request identity, with at most one final result per request.\",\n ),\n attention: z\n .enum([\"question\", \"failed\", \"stalled\", \"review\", \"conversation\"])\n .optional()\n .describe(\n \"Current human action: answer a question, inspect failed or stalled work, review a ready Change, or continue an external conversation.\",\n ),\n canFollowUp: z\n .boolean()\n .optional()\n .describe(\"Whether completed work can start a budgeted discussion in this conversation.\"),\n hasWorkflowFailure: z\n .boolean()\n .optional()\n .describe(\"Whether delegated workflow work has failed, independently of a pending question.\"),\n canCancel: z\n .boolean()\n .optional()\n .describe(\n \"Whether cancellation is available for the conversation or its delegated workflow work.\",\n ),\n historyNextCursor: z\n .string()\n .nullable()\n .optional()\n .describe(\"Continuation for earlier execution history.\"),\n relatedTasksNextCursor: z\n .string()\n .nullable()\n .optional()\n .describe(\"Continuation for additional related work.\"),\n history: z\n .array(\n z.strictObject({\n taskId: taskIdSchema.optional().describe(\"Task owning this execution, if any.\"),\n agent: z.string().describe(\"Agent that owns the provider execution.\"),\n message: z.string().describe(\"Initial request displayed for this execution.\"),\n attachments: imageAttachmentsSchema\n .optional()\n .describe(\"Images accompanying this execution's initial user request.\"),\n execution: executionReferenceSchema.describe(\"Authorized provider execution to replay.\"),\n }),\n )\n .readonly()\n .optional()\n .describe(\"Earlier executions, in conversation order, including replacement attempts.\"),\n relatedTasks: z\n .array(taskSchema)\n .readonly()\n .optional()\n .describe(\"Work linked to this conversation, including specialist delegations.\"),\n question: taskSchema\n .nullable()\n .describe(\"Open Factory question requiring an authenticated answer.\"),\n});\n/** The current operator-facing projection of a Factory session. */\nexport type SessionView = z.infer<typeof sessionViewSchema>;\n\n/** Validates a cursor-paginated page of operator-facing sessions. */\nexport const sessionPageSchema = z.strictObject({\n sessions: z.array(sessionSummarySchema).readonly().describe(\"Sessions in this page.\"),\n nextCursor: z\n .string()\n .min(1)\n .nullable()\n .default(null)\n .describe(\"Opaque cursor to pass unchanged for the next page, or null after the final page.\"),\n totalCount: z\n .number()\n .int()\n .nonnegative()\n .optional()\n .describe(\"Total matching sessions when explicitly requested.\"),\n});\n/** Cursor-paginated operator-facing sessions. */\nexport type SessionPage = z.infer<typeof sessionPageSchema>;\n\n/** Validates one configured repository exposed by the operator API. */\nexport const repositorySummarySchema = z.strictObject({\n id: repositoryIdSchema.describe(\"Stable configured repository identifier.\"),\n slug: repositorySlugSchema.describe(\"Configured owner/repository slug.\"),\n});\n/** Configured repository exposed by the operator API. */\nexport type RepositorySummary = z.infer<typeof repositorySummarySchema>;\n\n/** Validates repository slugs and their stable identifiers. */\nexport const repositoryDetailsSchema = z.strictObject({\n repositories: z\n .array(repositorySlugSchema)\n .readonly()\n .describe(\"Configured owner/repository slugs.\"),\n details: z\n .array(repositorySummarySchema)\n .readonly()\n .default([])\n .describe(\"Stable identifiers and slugs for configured repositories.\"),\n});\n/** Repository slugs and their stable configured identifiers. */\nexport type RepositoryDetails = z.infer<typeof repositoryDetailsSchema>;\n\n/** Validates a locally retained follow-up awaiting confirmed API acceptance. */\nexport const pendingFollowUpSchema = z\n .strictObject({\n sessionId: agentSessionIdSchema.describe(\"Conversation containing this follow-up.\"),\n operationId: z\n .string()\n .min(1)\n .max(200)\n .describe(\"Stable operation id retained until acceptance is confirmed.\"),\n executionId: z\n .string()\n .nullable()\n .describe(\"Execution observed before sending, or null before execution starts.\"),\n message: agentSessionMessageSchema,\n attachments: imageAttachmentsSchema\n .optional()\n .describe(\"Uploaded images accompanying this message.\"),\n turnPolicy: z.enum([\"steer\", \"queue\"]).describe(\"Requested turn policy.\"),\n })\n .refine(hasMessageContent, \"Enter a message or attach an image\");\n/** A locally retained follow-up awaiting confirmed API acceptance. */\nexport type PendingFollowUp = Readonly<\n Omit<z.output<typeof pendingFollowUpSchema>, \"attachments\">\n> & {\n readonly attachments?: readonly ImageAttachment[];\n};\n"],"mappings":";;;;;;;;;;;;;AA4BA,MAAa,iBAAiB,EAAE,aAAa;CAC3C,IAAI,EACD,OAAO,CAAC,CACR,MAAM,yBAAyB,CAAC,CAChC,SAAS,8EAA8E;CAC1F,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS,uBAAuB;CACxD,OAAO,wBACJ,SAAS,CAAC,CACV,SAAS,8DAA8D;CAC1E,UAAU,EACP,QAAQ,CAAC,CACT,SAAS,4EAA4E;CACxF,o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A0B,EAAE,aAAa;CACpD,cAAc,EACX,MAAM,oBAAoB,CAAC,CAC3B,SAAS,CAAC,CACV,SAAS,oCAAoC;CAChD,SAAS,EACN,MAAM,uBAAuB,CAAC,CAC9B,SAAS,CAAC,CACV,QAAQ,CAAC,CAAC,CAAC,CACX,SAAS,2DAA2D;AACzE,CAAC;;AAKD,MAAa,wBAAwB,EAClC,aAAa;CACZ,WAAW,qBAAqB,SAAS,yCAAyC;CAClF,aAAa,EACV,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAI,GAAG,CAAC,CACR,SAAS,6DAA6D;CACzE,aAAa,EACV,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,qEAAqE;CACjF,SAAS;CACT,aAAa,uBACV,SAAS,CAAC,CACV,SAAS,4CAA4C;CACxD,YAAY,EAAE,KAAK,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,SAAS,wBAAwB;AAC1E,CAAC,CAAC,CACD,OAAO,mBAAmB,oCAAoC"}
|
package/dist/api-task-graph.mjs
CHANGED
|
@@ -7,13 +7,22 @@ var TaskGraphAccessError = class extends Error {
|
|
|
7
7
|
this.status = status;
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
-
async function readSessionGraph(options, session) {
|
|
10
|
+
async function readSessionGraph(options, session, taskId) {
|
|
11
11
|
const { stores } = options;
|
|
12
|
-
|
|
12
|
+
const entryId = taskId ?? session.taskId;
|
|
13
|
+
if (!entryId) return {
|
|
13
14
|
rootTaskId: null,
|
|
14
15
|
nodes: []
|
|
15
16
|
};
|
|
16
|
-
const bound = await stores.tasks.get(
|
|
17
|
+
const bound = await stores.tasks.get(entryId);
|
|
18
|
+
if (taskId && taskId !== session.taskId) {
|
|
19
|
+
const original = session.taskId ? await stores.tasks.get(session.taskId) : null;
|
|
20
|
+
const replyTo = session.external?.replyTo ?? {
|
|
21
|
+
channel: "api",
|
|
22
|
+
address: session.id
|
|
23
|
+
};
|
|
24
|
+
if (!bound || bound.rootTaskId !== original?.rootTaskId && (bound.replyTo.channel !== replyTo.channel || bound.replyTo.address !== replyTo.address)) throw new TaskGraphAccessError(404, "Task graph not found");
|
|
25
|
+
}
|
|
17
26
|
if (!bound) throw new TaskGraphAccessError(409, "The entrypoint Task is unavailable; refresh the graph.");
|
|
18
27
|
const graph = await stores.graphs.get(bound.rootTaskId);
|
|
19
28
|
if (!graph || !graph.nodes.some((node) => node.taskId === bound.id)) throw new TaskGraphAccessError(409, "The Task graph is unavailable; refresh to retry.");
|
|
@@ -33,10 +42,10 @@ async function readSessionGraph(options, session) {
|
|
|
33
42
|
const owned = await sessions.get(task.replyTo.address);
|
|
34
43
|
if (!owned || owned.owner !== session.owner) throw new TaskGraphAccessError(404, "Task graph not found");
|
|
35
44
|
context = owned;
|
|
36
|
-
} else if (task.origin.operator !== session.owner && !await options.canAccessTask
|
|
45
|
+
} else if (task.origin.operator !== session.owner && !(options.canAccessTask ? await options.canAccessTask({ id: session.owner }, task) : options.sharedWorkspaceOwner === session.owner)) throw new TaskGraphAccessError(404, "Task graph not found");
|
|
37
46
|
const binding = task.work.route;
|
|
38
47
|
const route = binding ? options.routes.get(binding) : void 0;
|
|
39
|
-
const continuation =
|
|
48
|
+
const continuation = await stores.sessions.getContinuation(context.id, task.id);
|
|
40
49
|
const candidate = route?.agent ?? (binding?.id === "conversation" && binding.version === 1 && continuation?.agent === options.continuationAgent ? options.continuationAgent : void 0);
|
|
41
50
|
const agent = candidate && options.agents.some((item) => item.id === candidate) ? candidate : null;
|
|
42
51
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-task-graph.mjs","names":[],"sources":["../src/api-task-graph.ts"],"sourcesContent":["import type { FactoryApiOptions } from \"./api\";\nimport { agentSessionIdSchema, type AgentSession } from \"./schema/session\";\nimport type { Task } from \"./schema/task\";\nimport type { TaskId } from \"./schema/id\";\n\nexport class TaskGraphAccessError extends Error {\n constructor(\n readonly status: number,\n message: string,\n ) {\n super(message);\n }\n}\n\nexport async function readSessionGraph(options: FactoryApiOptions
|
|
1
|
+
{"version":3,"file":"api-task-graph.mjs","names":[],"sources":["../src/api-task-graph.ts"],"sourcesContent":["import type { FactoryApiOptions } from \"./api\";\nimport { agentSessionIdSchema, type AgentSession } from \"./schema/session\";\nimport type { Task } from \"./schema/task\";\nimport type { TaskId } from \"./schema/id\";\n\nexport class TaskGraphAccessError extends Error {\n constructor(\n readonly status: number,\n message: string,\n ) {\n super(message);\n }\n}\n\nexport async function readSessionGraph(\n options: FactoryApiOptions,\n session: AgentSession,\n taskId?: TaskId,\n) {\n const { stores } = options;\n const entryId = taskId ?? session.taskId;\n if (!entryId) return { rootTaskId: null, nodes: [] };\n const bound = await stores.tasks.get(entryId);\n if (taskId && taskId !== session.taskId) {\n const original = session.taskId ? await stores.tasks.get(session.taskId) : null;\n const replyTo = session.external?.replyTo ?? { channel: \"api\", address: session.id };\n if (\n !bound ||\n (bound.rootTaskId !== original?.rootTaskId &&\n (bound.replyTo.channel !== replyTo.channel || bound.replyTo.address !== replyTo.address))\n )\n throw new TaskGraphAccessError(404, \"Task graph not found\");\n }\n if (!bound)\n throw new TaskGraphAccessError(409, \"The entrypoint Task is unavailable; refresh the graph.\");\n const graph = await stores.graphs.get(bound.rootTaskId);\n if (!graph || !graph.nodes.some((node) => node.taskId === bound.id))\n throw new TaskGraphAccessError(409, \"The Task graph is unavailable; refresh to retry.\");\n const nodes: {\n task: Task;\n dependencyTaskIds: readonly TaskId[];\n session: AgentSession;\n agent: string | null;\n }[] = [];\n const repositories = new Map<string, Promise<boolean>>();\n const sessions = new Map<string, Promise<AgentSession | null>>();\n // Bound fan-out: a graph contains at most 256 directly addressed Tasks.\n for (let start = 0; start < graph.nodes.length; start += 16) {\n nodes.push(\n ...(await Promise.all(\n graph.nodes.slice(start, start + 16).map(async (node) => {\n const task = await stores.tasks.get(node.taskId);\n if (\n !task ||\n task.rootTaskId !== graph.rootTaskId ||\n task.parentTaskId !== node.parentTaskId\n )\n throw new TaskGraphAccessError(\n 409,\n \"Task graph membership is incomplete; refresh to retry.\",\n );\n for (const id of task.repositoryIds) {\n if (!repositories.has(id))\n repositories.set(\n id,\n stores.repositories\n .get(id)\n .then((repo) =>\n Boolean(repo?.enabled && options.repositories.includes(repo.slug)),\n ),\n );\n if (!(await repositories.get(id)))\n throw new TaskGraphAccessError(\n 403,\n \"The graph includes a repository that is no longer enabled and configured.\",\n );\n }\n let context: AgentSession = session;\n if (task.replyTo.channel === \"api\") {\n if (!sessions.has(task.replyTo.address))\n sessions.set(\n task.replyTo.address,\n stores.sessions.get(agentSessionIdSchema.parse(task.replyTo.address)),\n );\n const owned = await sessions.get(task.replyTo.address);\n if (!owned || owned.owner !== session.owner)\n throw new TaskGraphAccessError(404, \"Task graph not found\");\n context = owned;\n } else if (\n task.origin.operator !== session.owner &&\n !(options.canAccessTask\n ? await options.canAccessTask({ id: session.owner }, task)\n : options.sharedWorkspaceOwner === session.owner)\n ) {\n throw new TaskGraphAccessError(404, \"Task graph not found\");\n }\n const binding = task.work.route;\n const route = binding ? options.routes.get(binding) : undefined;\n const continuation = await stores.sessions.getContinuation(context.id, task.id);\n const candidate =\n route?.agent ??\n (binding?.id === \"conversation\" &&\n binding.version === 1 &&\n continuation?.agent === options.continuationAgent\n ? options.continuationAgent\n : undefined);\n const agent =\n candidate && options.agents.some((item) => item.id === candidate) ? candidate : null;\n return { task, dependencyTaskIds: node.dependencies, session: context, agent };\n }),\n )),\n );\n }\n return { rootTaskId: graph.rootTaskId, nodes };\n}\n"],"mappings":";;AAKA,IAAa,uBAAb,cAA0C,MAAM;CAEnC;CADX,YACE,QACA,SACA;EACA,MAAM,OAAO;EAHJ,KAAA,SAAA;CAIX;AACF;AAEA,eAAsB,iBACpB,SACA,SACA,QACA;CACA,MAAM,EAAE,WAAW;CACnB,MAAM,UAAU,UAAU,QAAQ;CAClC,IAAI,CAAC,SAAS,OAAO;EAAE,YAAY;EAAM,OAAO,CAAC;CAAE;CACnD,MAAM,QAAQ,MAA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+
import { AgentRouteRegistry } from "./agent-routes.mjs";
|
|
3
|
+
import { ImageAttachment, imagePartFilename } from "./image-input.mjs";
|
|
4
|
+
import { AgentSession, AgentSessionId, DirectAgentSession, ExternalAgentSession, TaskAgentSession, agentSessionIdSchema, agentSessionSchema } from "./schema/session.mjs";
|
|
5
|
+
import { Change } from "./schema/change.mjs";
|
|
6
|
+
import { Repository, RepositorySlug } from "./schema/repository.mjs";
|
|
7
|
+
import { Signal } from "./schema/signal.mjs";
|
|
8
|
+
import { FactoryStores, ImageInputError, SessionConflictError } from "./store/engine.mjs";
|
|
9
|
+
import { ApprovalStore } from "./store/approvals.mjs";
|
|
10
|
+
import { ConversationStore } from "./store/conversations.mjs";
|
|
1
11
|
import { InboxActivity, InboxActivityItem, inboxActivityItemSchema, inboxActivitySchema } from "./inbox-activity.mjs";
|
|
2
12
|
import { AgentModelConfig, ModelSettings, UpdateModelDefaults, agentModelConfigSchema, modelSettingsSchema, updateModelDefaultsSchema } from "./model-settings.mjs";
|
|
3
13
|
import { SessionPreview, SessionPreviews, sessionPreviewSchema, sessionPreviewsSchema } from "./session-previews.mjs";
|
|
4
14
|
import { SessionReview, SessionReviewCheck, SessionReviewIssue, SessionReviewScreenshot, sessionReviewCheckSchema, sessionReviewIssueSchema, sessionReviewSchema, sessionReviewScreenshotSchema } from "./session-review.mjs";
|
|
5
15
|
import { WorkspaceGitFilesOptions, workspaceGitFilesScript } from "./workspace-files-git.mjs";
|
|
6
16
|
import { WorkspaceFileEntry, WorkspaceFiles, WorkspaceFilesRequest, workspaceFileContentSchema, workspaceFileEntrySchema, workspaceFilesRequestSchema, workspaceFilesSchema, workspacePathSchema } from "./workspace-files.mjs";
|
|
7
|
-
import { Signal } from "./schema/signal.mjs";
|
|
8
|
-
import { Repository, RepositorySlug } from "./schema/repository.mjs";
|
|
9
|
-
import { ExecutionReference, Task } from "./schema/task.mjs";
|
|
10
|
-
import { AgentRouteRegistry } from "./agent-routes.mjs";
|
|
11
|
-
import { ImageAttachment, imagePartFilename } from "./image-input.mjs";
|
|
12
|
-
import { AgentSession, AgentSessionId, DirectAgentSession, ExternalAgentSession, TaskAgentSession, agentSessionIdSchema, agentSessionSchema } from "./schema/session.mjs";
|
|
13
|
-
import { FactoryStores, ImageInputError, SessionConflictError } from "./store/engine.mjs";
|
|
14
17
|
import { ApiPrincipal } from "./approval-contracts.mjs";
|
|
15
18
|
import { ResolveImageMessageInput, ResolveImageMessageStores, ResolvedImageMessage, ResolvedImageMessagePart, resolveImageMessage } from "./api-images.mjs";
|
|
16
19
|
import { DispatchBudget } from "./dispatch.mjs";
|
|
17
20
|
import { UnavailableWorkspaceDiffInput, WorkspaceDiff, WorkspaceDiffFile, unavailableWorkspaceDiff, workspaceDiffFileSchema, workspaceDiffSchema } from "./workspace-diff.mjs";
|
|
18
21
|
import { WorkspaceSnapshot, workspaceSnapshotSchema, workspaceSnapshotScript } from "./workspace-snapshot.mjs";
|
|
19
22
|
import { WorkspaceBaseBlob, WorkspaceBaseEntry, WorkspaceDiffAssemblyOptions, assembleWorkspaceDiff } from "./workspace-diff-assembly.mjs";
|
|
20
|
-
import { AnswerSessionQuestionRequest, ApiAgent, ApiAgentInput, ControlSessionRequest, CreateSessionRequest, RepositoryDetails, RepositorySummary, SendSessionMessageRequest, SessionInputResponse, SessionPage, SessionView, SubmitSessionInputRequest, answerSessionQuestionRequestSchema, apiAgentSchema, controlSessionRequestSchema, createSessionRequestSchema, repositoryDetailsSchema, repositorySummarySchema, sendSessionMessageRequestSchema, sessionInputResponseSchema, sessionPageSchema, sessionViewSchema, submitSessionInputRequestSchema } from "./api-contracts.mjs";
|
|
23
|
+
import { AnswerSessionQuestionRequest, ApiAgent, ApiAgentInput, ControlSessionRequest, CreateSessionRequest, RepositoryDetails, RepositorySummary, SendSessionMessageRequest, SessionInputResponse, SessionPage, SessionPullRequest, SessionView, SessionWorkGroup, SessionWorkResult, SessionWorkTask, SubmitSessionInputRequest, answerSessionQuestionRequestSchema, apiAgentSchema, controlSessionRequestSchema, createSessionRequestSchema, repositoryDetailsSchema, repositorySummarySchema, sendSessionMessageRequestSchema, sessionInputResponseSchema, sessionPageSchema, sessionPullRequestSchema, sessionPullRequestStateSchema, sessionViewSchema, sessionWorkGroupSchema, sessionWorkResultSchema, sessionWorkTaskSchema, submitSessionInputRequestSchema } from "./api-contracts.mjs";
|
|
21
24
|
//#region src/api.d.ts
|
|
22
25
|
/** Identifies the session launch requested by the Factory HTTP API. */
|
|
23
26
|
interface FactoryApiStartInput {
|
|
@@ -57,6 +60,36 @@ interface FactoryApiSessionPreviewsInput {
|
|
|
57
60
|
readonly tasks: readonly Task[];
|
|
58
61
|
readonly signal: AbortSignal;
|
|
59
62
|
}
|
|
63
|
+
/** Authorized Change and repository supplied to an application pull-request status reader. */
|
|
64
|
+
interface FactoryApiPullRequestStatusTarget {
|
|
65
|
+
readonly change: Change;
|
|
66
|
+
readonly repository: Repository;
|
|
67
|
+
}
|
|
68
|
+
/** Authorized pull requests supplied to an application-owned provider status reader. */
|
|
69
|
+
interface FactoryApiPullRequestStatusInput {
|
|
70
|
+
readonly pullRequests: readonly FactoryApiPullRequestStatusTarget[];
|
|
71
|
+
readonly signal: AbortSignal;
|
|
72
|
+
}
|
|
73
|
+
/** Current provider observation returned by an application pull-request status reader. */
|
|
74
|
+
interface FactoryApiPullRequestStatus {
|
|
75
|
+
readonly changeId: Change["id"];
|
|
76
|
+
readonly state: SessionPullRequest["state"];
|
|
77
|
+
readonly sync: SessionPullRequest["sync"];
|
|
78
|
+
readonly checkedAt: string;
|
|
79
|
+
readonly observedAt?: string;
|
|
80
|
+
readonly syncMessage?: string;
|
|
81
|
+
}
|
|
82
|
+
/** Authorized terminal request supplied to an application-owned conversation result presenter. */
|
|
83
|
+
interface FactoryApiSessionWorkPresentationInput {
|
|
84
|
+
/** Root Task that identifies the operator request. */
|
|
85
|
+
readonly root: Task;
|
|
86
|
+
/** Authorized root and child Task snapshots in the presented request. */
|
|
87
|
+
readonly tasks: readonly Task[];
|
|
88
|
+
/** Current pull requests produced by those Tasks. */
|
|
89
|
+
readonly pullRequests: readonly SessionPullRequest[];
|
|
90
|
+
}
|
|
91
|
+
/** Application adapter that turns validated terminal workflow output into one readable result. */
|
|
92
|
+
type FactoryApiSessionWorkPresenter = (input: FactoryApiSessionWorkPresentationInput) => Promise<SessionWorkResult | null>;
|
|
60
93
|
/** Authenticated caller and repository scope supplied to an external activity reader. */
|
|
61
94
|
interface FactoryApiInboxActivityInput {
|
|
62
95
|
/** Authenticated caller; the reader must apply its application's source access policy. */
|
|
@@ -71,7 +104,12 @@ interface FactoryApiOptions {
|
|
|
71
104
|
agentModels?: readonly AgentModelConfig[];
|
|
72
105
|
/** Explicit policy for saving shared repository defaults; absent denies mutations. */
|
|
73
106
|
canEditModelDefaults?(principal: ApiPrincipal, repository: Repository): Promise<boolean>;
|
|
74
|
-
stores: FactoryStores
|
|
107
|
+
stores: FactoryStores & {
|
|
108
|
+
readonly conversations: ConversationStore;
|
|
109
|
+
readonly approvals: ApprovalStore;
|
|
110
|
+
};
|
|
111
|
+
/** Explicit shared workspace grants list visibility to all configured-repository work in this owner scope. */
|
|
112
|
+
sharedWorkspaceOwner?: string;
|
|
75
113
|
agents: readonly ApiAgentInput[];
|
|
76
114
|
routes: AgentRouteRegistry;
|
|
77
115
|
repositories: readonly RepositorySlug[];
|
|
@@ -79,7 +117,9 @@ interface FactoryApiOptions {
|
|
|
79
117
|
authenticate(request: Request): Promise<ApiPrincipal | Response>;
|
|
80
118
|
/** Exact provider-qualified actors allowed to read and decide approvals. Absent disables approval access. */
|
|
81
119
|
operators?: readonly string[];
|
|
82
|
-
/**
|
|
120
|
+
/** Additional external-work policy. Without a shared workspace, absence denies Task access.
|
|
121
|
+
* Custom predicates are checked on each bounded page; exact listing totals are omitted.
|
|
122
|
+
*/
|
|
83
123
|
canAccessTask?(operator: {
|
|
84
124
|
id: string;
|
|
85
125
|
}, task: Task): Promise<boolean>;
|
|
@@ -91,6 +131,7 @@ interface FactoryApiOptions {
|
|
|
91
131
|
by: string;
|
|
92
132
|
}): Promise<Signal>;
|
|
93
133
|
resumeTask?(task: Task): Promise<ExecutionReference>;
|
|
134
|
+
/** Admits configured identity during first discovery or creation; must tolerate concurrent calls. */
|
|
94
135
|
ensureRepository(slug: RepositorySlug): Promise<Repository>;
|
|
95
136
|
start(input: FactoryApiStartInput): Promise<ExecutionReference>;
|
|
96
137
|
forward(input: FactoryApiForwardInput): Promise<Response>;
|
|
@@ -98,6 +139,12 @@ interface FactoryApiOptions {
|
|
|
98
139
|
sessionReview?(input: FactoryApiSessionReviewInput): Promise<SessionReview>;
|
|
99
140
|
/** Optional read-only preview reader; owns source selection, link access, expiry, and limits. */
|
|
100
141
|
sessionPreviews?(input: FactoryApiSessionPreviewsInput): Promise<SessionPreviews>;
|
|
142
|
+
/** Optional provider status reader; may reconcile objective lifecycle observations into application state. */
|
|
143
|
+
pullRequestStatuses?(input: FactoryApiPullRequestStatusInput): Promise<readonly FactoryApiPullRequestStatus[]>;
|
|
144
|
+
/** Maximum associated pull requests resolved for one conversation. Defaults to 50, maximum 100. */
|
|
145
|
+
maxSessionPullRequests?: number;
|
|
146
|
+
/** Optional application presenter for one final result after a request and its child work finish. */
|
|
147
|
+
presentSessionWork?: FactoryApiSessionWorkPresenter;
|
|
101
148
|
/** Optional external attention reader; owns caller authorization, sources, caching, and limits. */
|
|
102
149
|
inboxActivity?(input: FactoryApiInboxActivityInput): Promise<InboxActivity>;
|
|
103
150
|
workspaceDiff?(input: FactoryApiWorkspaceDiffInput): Promise<WorkspaceDiff>;
|
|
@@ -116,5 +163,5 @@ interface FactoryApi {
|
|
|
116
163
|
/** Creates the authenticated request handler for the public Factory HTTP API. */
|
|
117
164
|
declare function createFactoryApi(options: FactoryApiOptions): FactoryApi;
|
|
118
165
|
//#endregion
|
|
119
|
-
export { type AgentModelConfig, type AgentSession, type AgentSessionId, type AnswerSessionQuestionRequest, type ApiAgent, type ApiAgentInput, type ApiPrincipal, type ControlSessionRequest, type CreateSessionRequest, type DirectAgentSession, type ExternalAgentSession, FactoryApi, FactoryApiForwardInput, FactoryApiInboxActivityInput, FactoryApiOptions, FactoryApiSessionPreviewsInput, FactoryApiSessionReviewInput, FactoryApiStartInput, FactoryApiWorkspaceDiffInput, FactoryApiWorkspaceFilesInput, ImageInputError, type InboxActivity, type InboxActivityItem, type ModelSettings, type RepositoryDetails, type RepositorySummary, type ResolveImageMessageInput, type ResolveImageMessageStores, type ResolvedImageMessage, type ResolvedImageMessagePart, type SendSessionMessageRequest, SessionConflictError, type SessionInputResponse, type SessionPage, type SessionPreview, type SessionPreviews, type SessionReview, type SessionReviewCheck, type SessionReviewIssue, type SessionReviewScreenshot, type SessionView, type SubmitSessionInputRequest, type TaskAgentSession, type UnavailableWorkspaceDiffInput, type UpdateModelDefaults, type WorkspaceBaseBlob, type WorkspaceBaseEntry, type WorkspaceDiff, type WorkspaceDiffAssemblyOptions, type WorkspaceDiffFile, type WorkspaceFileEntry, type WorkspaceFiles, type WorkspaceFilesRequest, type WorkspaceGitFilesOptions, type WorkspaceSnapshot, agentModelConfigSchema, agentSessionIdSchema, agentSessionSchema, answerSessionQuestionRequestSchema, apiAgentSchema, assembleWorkspaceDiff, controlSessionRequestSchema, createFactoryApi, createSessionRequestSchema, imagePartFilename, inboxActivityItemSchema, inboxActivitySchema, modelSettingsSchema, repositoryDetailsSchema, repositorySummarySchema, resolveImageMessage, sendSessionMessageRequestSchema, sessionInputResponseSchema, sessionPageSchema, sessionPreviewSchema, sessionPreviewsSchema, sessionReviewCheckSchema, sessionReviewIssueSchema, sessionReviewSchema, sessionReviewScreenshotSchema, sessionViewSchema, submitSessionInputRequestSchema, unavailableWorkspaceDiff, updateModelDefaultsSchema, workspaceDiffFileSchema, workspaceDiffSchema, workspaceFileContentSchema, workspaceFileEntrySchema, workspaceFilesRequestSchema, workspaceFilesSchema, workspaceGitFilesScript, workspacePathSchema, workspaceSnapshotSchema, workspaceSnapshotScript };
|
|
166
|
+
export { type AgentModelConfig, type AgentSession, type AgentSessionId, type AnswerSessionQuestionRequest, type ApiAgent, type ApiAgentInput, type ApiPrincipal, type ControlSessionRequest, type CreateSessionRequest, type DirectAgentSession, type ExternalAgentSession, FactoryApi, FactoryApiForwardInput, FactoryApiInboxActivityInput, FactoryApiOptions, FactoryApiPullRequestStatus, FactoryApiPullRequestStatusInput, FactoryApiPullRequestStatusTarget, FactoryApiSessionPreviewsInput, FactoryApiSessionReviewInput, FactoryApiSessionWorkPresentationInput, FactoryApiSessionWorkPresenter, FactoryApiStartInput, FactoryApiWorkspaceDiffInput, FactoryApiWorkspaceFilesInput, ImageInputError, type InboxActivity, type InboxActivityItem, type ModelSettings, type RepositoryDetails, type RepositorySummary, type ResolveImageMessageInput, type ResolveImageMessageStores, type ResolvedImageMessage, type ResolvedImageMessagePart, type SendSessionMessageRequest, SessionConflictError, type SessionInputResponse, type SessionPage, type SessionPreview, type SessionPreviews, type SessionPullRequest, type SessionReview, type SessionReviewCheck, type SessionReviewIssue, type SessionReviewScreenshot, type SessionView, type SessionWorkGroup, type SessionWorkResult, type SessionWorkTask, type SubmitSessionInputRequest, type TaskAgentSession, type UnavailableWorkspaceDiffInput, type UpdateModelDefaults, type WorkspaceBaseBlob, type WorkspaceBaseEntry, type WorkspaceDiff, type WorkspaceDiffAssemblyOptions, type WorkspaceDiffFile, type WorkspaceFileEntry, type WorkspaceFiles, type WorkspaceFilesRequest, type WorkspaceGitFilesOptions, type WorkspaceSnapshot, agentModelConfigSchema, agentSessionIdSchema, agentSessionSchema, answerSessionQuestionRequestSchema, apiAgentSchema, assembleWorkspaceDiff, controlSessionRequestSchema, createFactoryApi, createSessionRequestSchema, imagePartFilename, inboxActivityItemSchema, inboxActivitySchema, modelSettingsSchema, repositoryDetailsSchema, repositorySummarySchema, resolveImageMessage, sendSessionMessageRequestSchema, sessionInputResponseSchema, sessionPageSchema, sessionPreviewSchema, sessionPreviewsSchema, sessionPullRequestSchema, sessionPullRequestStateSchema, sessionReviewCheckSchema, sessionReviewIssueSchema, sessionReviewSchema, sessionReviewScreenshotSchema, sessionViewSchema, sessionWorkGroupSchema, sessionWorkResultSchema, sessionWorkTaskSchema, submitSessionInputRequestSchema, unavailableWorkspaceDiff, updateModelDefaultsSchema, workspaceDiffFileSchema, workspaceDiffSchema, workspaceFileContentSchema, workspaceFileEntrySchema, workspaceFilesRequestSchema, workspaceFilesSchema, workspaceGitFilesScript, workspacePathSchema, workspaceSnapshotSchema, workspaceSnapshotScript };
|
|
120
167
|
//# sourceMappingURL=api.d.mts.map
|