@agent-compose/sdk 0.8.1 → 0.8.3

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 (48) hide show
  1. package/dist/agent/__tests__/perf-sampler.test.d.ts +10 -0
  2. package/dist/agent/agent-context.d.ts +1 -1
  3. package/dist/agent/agent-loop.d.ts +5 -1
  4. package/dist/agent/desktop-open.d.ts +184 -0
  5. package/dist/agent/perf-sampler.d.ts +99 -0
  6. package/dist/agent/services-manifest.d.ts +88 -0
  7. package/dist/agent/services-restore.d.ts +58 -0
  8. package/dist/client.d.ts +189 -15
  9. package/dist/display.d.ts +17 -0
  10. package/dist/index.d.ts +14 -5
  11. package/dist/index.js +1625 -120
  12. package/dist/runtimes/_cli-agent.d.ts +372 -2
  13. package/dist/runtimes/claude-code.d.ts +12 -0
  14. package/dist/runtimes/codex.buildcommand.test.d.ts +9 -0
  15. package/dist/runtimes/codex.d.ts +8 -0
  16. package/dist/runtimes/openai-desktop.js +1555 -120
  17. package/dist/runtimes/session-env.test.d.ts +14 -0
  18. package/dist/sandbox/sizes.d.ts +120 -30
  19. package/dist/sandbox.d.ts +1 -1
  20. package/dist/types/api-conversations.d.ts +476 -1
  21. package/dist/types/api-factory.d.ts +164 -7
  22. package/dist/types/api-runs.d.ts +23 -1
  23. package/dist/types/protocol.d.ts +32 -1
  24. package/dist/types/runtime.d.ts +120 -0
  25. package/dist/types/workflow-metadata.d.ts +6 -5
  26. package/package.json +1 -1
  27. package/src/agent/agent-context.ts +128 -28
  28. package/src/agent/agent-loop.ts +10 -3
  29. package/src/agent/desktop-open.ts +418 -0
  30. package/src/agent/perf-sampler.ts +202 -0
  31. package/src/agent/services-manifest.ts +356 -0
  32. package/src/agent/services-restore.ts +195 -0
  33. package/src/client.ts +384 -32
  34. package/src/display.ts +44 -1
  35. package/src/index.ts +74 -7
  36. package/src/runtimes/_cli-agent.ts +1160 -67
  37. package/src/runtimes/claude-code.ts +187 -12
  38. package/src/runtimes/codex.ts +65 -2
  39. package/src/sandbox/providers/e2b.ts +8 -4
  40. package/src/sandbox/providers/local.ts +16 -4
  41. package/src/sandbox/sizes.ts +127 -44
  42. package/src/sandbox.ts +8 -0
  43. package/src/types/api-conversations.ts +461 -2
  44. package/src/types/api-factory.ts +165 -7
  45. package/src/types/api-runs.ts +25 -1
  46. package/src/types/protocol.ts +30 -1
  47. package/src/types/runtime.ts +122 -0
  48. package/src/types/workflow-metadata.ts +6 -5
package/src/display.ts CHANGED
@@ -70,7 +70,11 @@ export type DisplayMarker =
70
70
  | { kind: "image"; path: string; factorySlug?: string }
71
71
  | { kind: "table"; columns: DisplayTableColumn[]; rows: Array<Record<string, DisplayTableCell>>; truncated: boolean }
72
72
  | { kind: "chart"; chartKind: DisplayChartKind; series: DisplayChartSeries[]; xLabel?: string; yLabel?: string }
73
- | { kind: "ask"; askId: string; prompt: string; options?: DisplayAskOption[]; freeText: boolean };
73
+ | { kind: "ask"; askId: string; prompt: string; options?: DisplayAskOption[]; freeText: boolean }
74
+ /** A desktop snapshot (`agentc display desktop`): the CLI captured the
75
+ * session VM's screen to `path` on the session's drive branch. The card
76
+ * renders the snapshot + an "Open desktop" door to the live surface. */
77
+ | { kind: "desktop"; path: string; factorySlug?: string; capturedAt?: string; note?: string };
74
78
 
75
79
  const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
76
80
 
@@ -273,6 +277,9 @@ export function clampAskOptions(raw: unknown): DisplayAskOption[] {
273
277
  return options;
274
278
  }
275
279
 
280
+ /** Desktop-snapshot note bound — one caption line on the card. */
281
+ export const DESKTOP_NOTE_MAX_CHARS = 200;
282
+
276
283
  /** One-line JSON marker — exactly what `agentc display` prints. */
277
284
  export function serializeDisplayMarker(marker: DisplayMarker): string {
278
285
  return JSON.stringify({ [DISPLAY_MARKER_KEY]: DISPLAY_MARKER_VERSION, ...marker });
@@ -350,6 +357,21 @@ export function parseDisplayMarker(line: string): DisplayMarker | null {
350
357
  ...(yLabel !== undefined ? { yLabel } : {}),
351
358
  };
352
359
  }
360
+ case "desktop": {
361
+ const path = str("path");
362
+ if (!path || !isPlausibleDrivePath(path)) return null;
363
+ // capturedAt must parse as a real instant — a garbage stamp is
364
+ // dropped rather than rendered as "Invalid Date" on the card.
365
+ const capturedAt = str("capturedAt");
366
+ const capturedOk = capturedAt !== undefined && Number.isFinite(Date.parse(capturedAt));
367
+ const note = str("note");
368
+ return {
369
+ kind: "desktop", path,
370
+ ...(str("factorySlug") ? { factorySlug: str("factorySlug") } : {}),
371
+ ...(capturedOk ? { capturedAt } : {}),
372
+ ...(note !== undefined ? { note: note.slice(0, DESKTOP_NOTE_MAX_CHARS) } : {}),
373
+ };
374
+ }
353
375
  case "ask": {
354
376
  const askId = str("askId");
355
377
  const rawPrompt = str("prompt");
@@ -384,6 +406,9 @@ export type AgentcInvocation =
384
406
  | { verb: "display-document"; path: string; factorySlug?: string }
385
407
  | { verb: "display-plan" }
386
408
  | { verb: "display-image"; path: string; factorySlug?: string }
409
+ /** `agentc display desktop` — the CLI captures the screen itself, so the
410
+ * call has no positional path; the marker in the result names the file. */
411
+ | { verb: "display-desktop" }
387
412
  /** Directive verb — detection only arms the tool_call promotion; the
388
413
  * result keeps its raw output so the directive marker reaches the cloud
389
414
  * executor. Same for table `source:"file"`, diff, and ask-with-approver. */
@@ -432,6 +457,7 @@ const VALUE_FLAGS = new Set([
432
457
  "--factory", "--input", "--entries", "--url", "--api-key", "--limit",
433
458
  "--thread", "--content-type", "--file", "--out", "--revision", "--ended-at",
434
459
  "--data", "--kind", "--from", "--to", "--prompt", "--options", "--approver",
460
+ "--note",
435
461
  ]);
436
462
 
437
463
  /** Detect a known agentc invocation inside a shell command string. Returns
@@ -514,6 +540,8 @@ export function detectAgentcInvocation(command: string): AgentcInvocation | null
514
540
  const path = drivePath(args[2]);
515
541
  return path ? { verb: "display-image", path, ...withSlug } : null;
516
542
  }
543
+ case "desktop":
544
+ return { verb: "display-desktop" };
517
545
  case "preview": {
518
546
  const path = drivePath(args[2]);
519
547
  return path ? { verb: "display-preview", path } : null;
@@ -700,6 +728,8 @@ export function createDisplayPromoter(ctx: DisplayPromoterContext = {}): Display
700
728
  return call("display_plan", {});
701
729
  case "display-image":
702
730
  return call("display_image", { path: invocation.path, ...factoryRef(invocation.factorySlug) });
731
+ case "display-desktop":
732
+ return call("display_desktop", {});
703
733
  case "display-preview":
704
734
  return call("display_preview", { path: invocation.path, ...factoryRef(undefined) });
705
735
  case "display-table":
@@ -789,6 +819,19 @@ export function createDisplayPromoter(ctx: DisplayPromoterContext = {}): Display
789
819
  ...factoryRef(m?.factorySlug ?? inv.factorySlug),
790
820
  })];
791
821
  }
822
+ case "display-desktop": {
823
+ // No marker → the capture failed before it could name a file —
824
+ // keep the raw output (the CLI's own error is the feedback);
825
+ // a desktop card without a snapshot would lie.
826
+ const marker = findDisplayMarker(text);
827
+ if (marker?.kind !== "desktop") return [result(msg.output)];
828
+ return [result({
829
+ path: marker.path,
830
+ ...factoryRef(marker.factorySlug),
831
+ capturedAt: marker.capturedAt ?? null,
832
+ note: marker.note ?? null,
833
+ })];
834
+ }
792
835
  case "display-table": {
793
836
  // File-sourced tables are a DIRECTIVE: keep the raw output so the
794
837
  // marker inside it reaches the cloud executor (the real card pair).
package/src/index.ts CHANGED
@@ -24,8 +24,10 @@ export type {
24
24
  AgentRuntime,
25
25
  McpServerConfig,
26
26
  ModelExecutionContract,
27
+ RunnerLivenessVerdict,
27
28
  ToolCallGateResult,
28
29
  RuntimeOptions,
30
+ TurnExitNotify,
29
31
  } from "./types/runtime.js";
30
32
 
31
33
  // Workflow types and runtime utilities
@@ -98,6 +100,7 @@ export type {
98
100
  AgentMessageDone,
99
101
  AgentMessageError,
100
102
  AgentMessageUsage,
103
+ AgentMessageTaskNotification,
101
104
  AgentStatus,
102
105
  } from "./types/protocol.js";
103
106
 
@@ -117,15 +120,16 @@ export type {
117
120
  InlineWorkflowPayload, InvokeInlineOptions, InvokeInlineAndWaitOptions,
118
121
  ListSnapshotsOptions, TemplateRow, ListTemplatesOptions,
119
122
  CreateFactoryInput, UpdateFactoryInput,
120
- SecretOptions, SetSecretResult, SecretListEntry,
123
+ SecretOptions, SetSecretResult, SecretListEntry, SessionSecretEntry, SessionSecretInput, SessionSecretRequestCreated, SessionSecretRequestStatus,
121
124
  CreateApiKeyInput, StreamRunLogsOptions,
122
125
  TeamMember, Mention, CreateMentionsInput,
123
126
  EventSubjectType, EventRow, ReportEventInput, ListEventsOptions, ListEventsResult,
124
127
  RunLogLine, ListRunLogsOptions,
125
128
  RunListEntry, ListRunsOptions, RunDetail,
126
129
  FundingLane, RunFundingStamp, RunFundingUsageRow, RunFundingResponse,
130
+ RunStepUsage, RunStepUsageResponse,
127
131
  RegisteredRuntime, RunState, RunStatus, FactoryRow, SnapshotListEntry, SnapshotListResponse,
128
- ApiKey, ApiKeyCreated,
132
+ ApiKey, ApiKeyCreated, ListApiKeysOptions, ApiKeyPage,
129
133
  UsageRollupRow, UsageResponse,
130
134
  CancelRunResponse,
131
135
  RequestAgentPauseOptions, RequestAgentPauseResponse,
@@ -135,18 +139,28 @@ export type {
135
139
  ConversationMessagePart, ConversationRow, ConversationMessageRow,
136
140
  ConversationsPage, ConversationDetail, ConversationThread,
137
141
  ConversationPageContext, SendConversationMessageInput, SendConversationMessageResult,
142
+ UnnotifiedMention,
138
143
  ConversationTurnState, ConversationPresenceSnapshot, StreamConversationOptions, AgentListRow,
139
144
  CreateCloudSessionInput, CloudSessionCreated,
140
145
  // Cloud-session developer surface (ADR-0052)
141
- SessionPreview, PreviewOpened, OpenPreviewInput, SessionForked,
146
+ SessionPreview, PreviewOpened, OpenPreviewInput, SessionForked, BackgroundWorkHeld,
142
147
  // Session branch proposals (ADR-0053)
143
- SessionFileChange, SessionChangeSet,
144
- SessionMergeReportDetail, SessionMergeReport, SessionDiscardReport,
148
+ SessionFileChange, SessionChangeSet, SessionChangeStats, SessionDiffReviewBound, ReviewSuggestion,
149
+ ReviewSuggestionInput, ReviewNotesPublished, ReviewGitCredential, SessionReviewDocument,
150
+ ReviewSuggestionDecision, ReviewSuggestionDecisions,
151
+ SessionMergeReportDetail, SessionMergeReport, SessionMergeGated, SessionDiscardReport,
152
+ SessionPreflightFileRow, SessionChangePreflight, SessionRebaseReport,
145
153
  // User drive mounts (`agentc files mount` on a human's own machine)
146
154
  DriveMountSession, CreateDriveMountSessionInput,
147
155
  // Channel-attached sessions (ADR-0057)
148
156
  ChannelSessionStatus, ChannelSessionRow, ChannelSessionsResponse, SessionChannelMessagePosted,
157
+ // Session→session messaging + branch claims
158
+ SessionDirectMessageSent, BranchClaimInfo, BranchClaimGranted, BranchClaimsReleased, BranchClaimState,
159
+ // Sandbox perf history (session_perf_rollups)
160
+ SessionPerfBucket, SessionPerfHistoryPage, FactoryPerfSummary,
149
161
  FactoryFileSearchRow, FactoryFolderSearchRow, SearchFactoryFilesOptions, FactoryFileSearchResult, PublicFileLinkState,
162
+ // Drive file listing (live + browse-at-head)
163
+ FactoryFileListRow, ListFactoryFilesOptions, FactoryFileListPage,
150
164
  // Membership-scoped authorization (ADR-0045)
151
165
  ConversationMemberRole, ConversationMember,
152
166
  DocumentCapability, TemplateCapability, ScopeGrant, ArtifactScope,
@@ -243,6 +257,33 @@ export type { CodexRuntimeConfig, CodexReasoningEffort } from "./runtimes/codex.
243
257
  export { default as codexRuntime } from "./runtimes/codex.js";
244
258
  // Reasoning-effort level a CLI runtime turn may carry (claude-code / codex).
245
259
  export type { CliReasoningEffort } from "./runtimes/_cli-agent.js";
260
+ // Guest durable-plane helpers (ADR-0068): the server-side CloudTurnWorkflow
261
+ // activities launch/probe/tail the SAME durable trio the CLI-agent transport
262
+ // writes, so the shell fragments and probe parsers are shared — one source
263
+ // of truth for the guest file contract. Server-side consumers only (these
264
+ // modules read process.env at load; never import them into a workflow VM).
265
+ export {
266
+ shellQuote, uniquePromptPath,
267
+ turnLivenessProbeCommand, parseTurnProbeOutput, livenessVerdictFromReading,
268
+ runnerBusySentinelFragment, exitEventPushCommand,
269
+ injectAppendAndAckCommand, INJECT_ACK_EXEC_TIMEOUT_MS,
270
+ streamInputFeederFragment, sessionEnvSourceFragment, credEnvSourceFragment,
271
+ residentFeederFragment, residentIdleCheckFragment, residentIdleWatchdogFragment,
272
+ residentResultCountCommand, deferredExitEventPushCommand,
273
+ RESIDENT_IDLE_TTL_S, RESIDENT_WATCHDOG_POLL_S, RESIDENT_RESULT_LINE_PREFIX,
274
+ SESSION_ENV_FILE_RELPATH,
275
+ LAUNCH_EXEC_TIMEOUT_MS, TURN_PROBE_TIMEOUT_MS,
276
+ INSTALL_PROBE_TIMEOUT_MS, CLI_INSTALL_TIMEOUT_MS,
277
+ RUNNER_HEARTBEAT_INTERVAL_SECONDS, RUNNER_HEARTBEAT_STALE_MS,
278
+ } from "./runtimes/_cli-agent.js";
279
+ export type { TurnProbeReading, CliAgentSpec } from "./runtimes/_cli-agent.js";
280
+ // Guest perf sampling (the `.perf` token contract riding the durable trio).
281
+ export {
282
+ perfSamplerFunctionFragment, standalonePerfProbeCommand,
283
+ parsePerfToken, parsePerfProbeOutput,
284
+ PERF_SAMPLE_EVERY_BEATS, PERF_PROBE_WINDOW_SECONDS, PERF_TOKEN_MAX_CHARS,
285
+ } from "./agent/perf-sampler.js";
286
+ export type { GuestPerfSample } from "./agent/perf-sampler.js";
246
287
  export { createAmpRuntime } from "./runtimes/amp.js";
247
288
  export type { AmpRuntimeConfig } from "./runtimes/amp.js";
248
289
  export { default as ampRuntime } from "./runtimes/amp.js";
@@ -278,8 +319,11 @@ export { createSandbox, reconnectSandbox, killAllSandboxes, killSandboxById,
278
319
  getSandboxQuotas, listOwnedSandboxes, deleteSandboxSnapshot, snapshotResolves,
279
320
  makeSandboxProvider, makeDesktopSandboxProvider,
280
321
  parseSseExecStream, AGENT_COMPOSE_TAG,
281
- SANDBOX_VCPUS, DEFAULT_SANDBOX_SIZE, E2B_TEMPLATE_SIZES,
282
- isE2bSupportedSize, e2bMachineSpec, e2bBaseTemplate, e2bAgentEnvTemplate,
322
+ SANDBOX_SIZES, SANDBOX_MACHINES, SANDBOX_VCPUS, DEFAULT_SANDBOX_SIZE, SESSION_DEFAULT_SANDBOX_SIZE,
323
+ E2B_TEMPLATE_SIZES, E2B_MAX_VCPUS, E2B_MAX_MEMORY_MB,
324
+ VERCEL_MEMORY_MB_PER_VCPU,
325
+ isE2bSupportedSize, isVercelSupportedSize, sandboxSizeLabel,
326
+ e2bMachineSpec, e2bBaseTemplate, e2bAgentEnvTemplate,
283
327
  isPlatformE2bTemplateAlias,
284
328
  // ADR-0038 "Computer" — the per-member persistent desktop machine template.
285
329
  E2B_DEVBOX_TEMPLATE, E2B_DEVBOX_SPEC, E2B_DEVBOX_RECIPE_VERSION,
@@ -382,6 +426,28 @@ export { agent } from "./agent/run-agent.js";
382
426
  export type { AgentOpts } from "./agent/run-agent.js";
383
427
  export { AGENT_COMPOSE_MANUAL, buildAgentContextDoc, writeAgentContext, buildAddedSessionBrief } from "./agent/agent-context.js";
384
428
  export type { AgentConnectorInfo, AddedSessionBriefParams } from "./agent/agent-context.js";
429
+ export {
430
+ AC_OPEN_PATH, AC_OPEN_STATE_DIR, AC_OPEN_SHIM_PATHS, AC_OPEN_SCRIPT, AC_OPEN_SHIM,
431
+ installDesktopOpenCmd,
432
+ BROWSER_BACKFILL_PIDFILE, BROWSER_BACKFILL_LOG, BROWSER_BACKFILL_FAILED,
433
+ BROWSER_INSTALL_IN_PROGRESS_MSG, browserBackfillCmd, browserBackfillStatusCmd,
434
+ CHROMIUM_DEFAULTS, CHROMIUM_DEFAULTS_PATH, installChromiumDefaultsCmd,
435
+ } from "./agent/desktop-open.js";
436
+ // Durable services manifest (.ac/services.yml) — the machine is cattle, the
437
+ // manifest is the pet. Shared by the server's fresh-boot auto-restore, the
438
+ // resize pre-kill dump hook, and `agentc services`.
439
+ export {
440
+ SERVICES_MANIFEST_RELPATH, SERVICES_MAX, SERVICE_NAME_RE,
441
+ parseServicesManifest, renderServicesManifest,
442
+ } from "./agent/services-manifest.js";
443
+ export type {
444
+ ServiceEntry, ServiceHealth, ServiceDataHooks, ServicesManifest, ParseServicesManifestResult,
445
+ } from "./agent/services-manifest.js";
446
+ export {
447
+ SERVICES_STATE_DIR, SERVICE_STATUS_PREFIX, SERVICE_HEALTH_TIMEOUT_S,
448
+ servicesRestoreScript, servicesDumpScript, parseServicesRestoreOutput, formatServicesRestoreSummary,
449
+ } from "./agent/services-restore.js";
450
+ export type { ServiceRestoreOutcome, ServiceRestoreStatus } from "./agent/services-restore.js";
385
451
  export { AgentMessageSchema, parseAgentResponse } from "./agent/protocol.js";
386
452
  export { importSourceModule, TMP_DIR, LATEST_VERSION } from "./utils/source-loader.js";
387
453
 
@@ -393,6 +459,7 @@ export {
393
459
  TABLE_MAX_COLUMNS, TABLE_MAX_ROWS, TABLE_CELL_MAX_CHARS,
394
460
  CHART_MAX_SERIES, CHART_MAX_POINTS_PER_SERIES, CHART_LABEL_MAX_CHARS,
395
461
  ASK_PROMPT_MAX_CHARS, ASK_MAX_OPTIONS, ASK_OPTION_ID_MAX_CHARS, ASK_OPTION_LABEL_MAX_CHARS,
462
+ DESKTOP_NOTE_MAX_CHARS,
396
463
  DRIVE_PATH_MAX_CHARS, isPlausibleDrivePath,
397
464
  serializeDisplayMarker, parseDisplayMarker, findDisplayMarker, clampPlanEntries,
398
465
  clampTableData, clampChartSeries, clampChartAxisLabel, clampAskOptions,