openpond 0.0.30-bootstrap.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +128 -0
- package/LICENSE +21 -0
- package/README.md +162 -0
- package/RELEASE.md +20 -0
- package/dist/api/core.d.ts +22 -0
- package/dist/api/deployments.d.ts +30 -0
- package/dist/api/types.d.ts +624 -0
- package/dist/api.d.ts +90 -0
- package/dist/cache.d.ts +22 -0
- package/dist/chunks/app-layer-YKXEQGOW.js +163 -0
- package/dist/chunks/apps-GGSIN2ZF.js +539 -0
- package/dist/chunks/chunk-3CC6MH35.js +1663 -0
- package/dist/chunks/chunk-3Y4EL3P6.js +1090 -0
- package/dist/chunks/chunk-4HYJG2JE.js +3875 -0
- package/dist/chunks/chunk-5G4E547X.js +294 -0
- package/dist/chunks/chunk-74O6FGVN.js +598 -0
- package/dist/chunks/chunk-AUJLPKGI.js +632 -0
- package/dist/chunks/chunk-BYAPLT37.js +744 -0
- package/dist/chunks/chunk-FUP7EGT7.js +1845 -0
- package/dist/chunks/chunk-I6HN3ZGW.js +88 -0
- package/dist/chunks/chunk-KRKGHVMQ.js +294 -0
- package/dist/chunks/chunk-LHYK6QO2.js +1300 -0
- package/dist/chunks/chunk-NLBKZZEK.js +224 -0
- package/dist/chunks/chunk-OG75GMVO.js +1 -0
- package/dist/chunks/chunk-Q57SVPEH.js +11663 -0
- package/dist/chunks/chunk-UACZUFIA.js +47 -0
- package/dist/chunks/chunk-VQX33YAG.js +5135 -0
- package/dist/chunks/chunk-W5GKHH77.js +168 -0
- package/dist/chunks/chunk-WYDVQOBL.js +17581 -0
- package/dist/chunks/chunk-XSAXENQD.js +4167 -0
- package/dist/chunks/chunk-Y6G6WRTG.js +210 -0
- package/dist/chunks/cli-NVKNE4AZ.js +11 -0
- package/dist/chunks/cli-X3HPLSOV.js +19 -0
- package/dist/chunks/core-commands-IM2UKLU4.js +41 -0
- package/dist/chunks/extend-YXCBULPO.js +84 -0
- package/dist/chunks/harness-GMK6IY2U.js +140 -0
- package/dist/chunks/help-LMH5FGT2.js +65 -0
- package/dist/chunks/opchat-BWXZ32GX.js +169 -0
- package/dist/chunks/organizations-4ISQRGMQ.js +738 -0
- package/dist/chunks/profile-NLDZDT3L.js +1110 -0
- package/dist/chunks/project-agent-ZPVO25HA.js +892 -0
- package/dist/chunks/sandbox-command-5GFJ2U3V.js +1652 -0
- package/dist/chunks/sandbox-template-LZN4F55Z.js +1646 -0
- package/dist/chunks/src-3RBI4DNN.js +3595 -0
- package/dist/chunks/src-EYXQS6XD.js +73427 -0
- package/dist/chunks/teams-bot-WP3FHKGA.js +137 -0
- package/dist/cli.js +77 -0
- package/dist/client-types.d.ts +222 -0
- package/dist/client.d.ts +19 -0
- package/dist/config.d.ts +184 -0
- package/dist/hosted-chat.d.ts +162 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +25481 -0
- package/dist/indicators.d.ts +38 -0
- package/dist/opchat-smoke.d.ts +47 -0
- package/dist/private-json-file.d.ts +3 -0
- package/dist/profile/local-profile-types.d.ts +160 -0
- package/dist/profile/local-profile.d.ts +69 -0
- package/dist/profile/profile-catalog.d.ts +14 -0
- package/dist/profile/profile-git.d.ts +17 -0
- package/dist/profile/profile-promotion.d.ts +21 -0
- package/dist/profile/profile-setup-gate.d.ts +22 -0
- package/dist/profile/profile-skills.d.ts +30 -0
- package/dist/profile/profile-source-upload.d.ts +29 -0
- package/dist/profile/source-upload-cache.d.ts +29 -0
- package/dist/sandbox/async-request-options.d.ts +2 -0
- package/dist/sandbox/client-handles.d.ts +113 -0
- package/dist/sandbox/client.d.ts +348 -0
- package/dist/sandbox/runtime-handle.d.ts +36 -0
- package/dist/sandbox/sandbox-instance-client.d.ts +72 -0
- package/dist/sandbox/smoke.d.ts +3 -0
- package/dist/sandbox/stream.d.ts +7 -0
- package/dist/sandbox/types/billing.d.ts +176 -0
- package/dist/sandbox/types/client.d.ts +103 -0
- package/dist/sandbox/types/core.d.ts +140 -0
- package/dist/sandbox/types/index.d.ts +14 -0
- package/dist/sandbox/types/io.d.ts +240 -0
- package/dist/sandbox/types/microsoft-teams-bot.d.ts +51 -0
- package/dist/sandbox/types/org-project-agent.d.ts +610 -0
- package/dist/sandbox/types/record.d.ts +53 -0
- package/dist/sandbox/types/responses.d.ts +295 -0
- package/dist/sandbox/types/runtime-profiles.d.ts +15 -0
- package/dist/sandbox/types/runtime.d.ts +152 -0
- package/dist/sandbox/types/schedules.d.ts +141 -0
- package/dist/sandbox/types/snapshots.d.ts +205 -0
- package/dist/sandbox/types/workflow-modes.d.ts +1 -0
- package/dist/sandbox/types/workload-sources.d.ts +20 -0
- package/dist/sandbox/url.d.ts +2 -0
- package/dist/sandbox-template/manifest.d.ts +304 -0
- package/dist/sandbox-template/manifest.js +18381 -0
- package/dist/skills/openpond-cli/SKILL.md +49 -0
- package/dist/skills/openpond-desktop-harness/SKILL.md +113 -0
- package/dist/skills/openpond-desktop-harness/agents/openai.yaml +4 -0
- package/dist/skills/openpond-taskset-authoring/SKILL.md +38 -0
- package/dist/skills/openpond-taskset-authoring/references/graders-and-rewards.md +11 -0
- package/dist/skills/openpond-taskset-authoring/references/method-selection.md +12 -0
- package/dist/skills/openpond-taskset-authoring/references/privacy-and-provenance.md +8 -0
- package/dist/skills/openpond-taskset-authoring/references/task-design.md +13 -0
- package/dist/stream.d.ts +20 -0
- package/dist/types.d.ts +57 -0
- package/dist/urls.d.ts +4 -0
- package/dist/web/assets/AppsView-Bu-Nc3Ew.js +1 -0
- package/dist/web/assets/AppsView-DIhprTIC.css +1 -0
- package/dist/web/assets/BrowserSidebar-CCguQ-DR.js +1 -0
- package/dist/web/assets/BrowserSidebar-D9i7gQzw.css +1 -0
- package/dist/web/assets/CloudWorkView-DNoPIlMj.css +1 -0
- package/dist/web/assets/CloudWorkView-Dr3xqLE5.js +1 -0
- package/dist/web/assets/CommandMenu-CnodJFHD.js +1 -0
- package/dist/web/assets/CommandMenu-hNQCm8mw.css +1 -0
- package/dist/web/assets/CommunityView-CIbjNUZr.js +1 -0
- package/dist/web/assets/CommunityView-DSik4sd2.css +1 -0
- package/dist/web/assets/GetStartedView-C3ZrnEz5.css +1 -0
- package/dist/web/assets/GetStartedView-C8nyH_PT.js +1 -0
- package/dist/web/assets/LabsExtensions-GtJzxDnK.js +1 -0
- package/dist/web/assets/LabsProfile-DG7rWYur.js +1 -0
- package/dist/web/assets/LabsRoute-D6MDHBzq.js +2 -0
- package/dist/web/assets/LabsRoute-TEt9j1vB.css +1 -0
- package/dist/web/assets/LabsSignals-BfsDN86w.js +1 -0
- package/dist/web/assets/LabsSignals-D6iA6Ryl.css +1 -0
- package/dist/web/assets/NewProjectDialog-CaKiCoVS.js +1 -0
- package/dist/web/assets/ProfileSettingsSection-DTQS2DVL.css +1 -0
- package/dist/web/assets/ProfileSettingsSection-DxEzoF3K.js +1 -0
- package/dist/web/assets/ProfileView-CEscW7Ru.js +1 -0
- package/dist/web/assets/SettingsView-DwbGu8Kj.css +1 -0
- package/dist/web/assets/SettingsView-JIRR_FO4.js +63 -0
- package/dist/web/assets/TeamChatView-B5M1ThhJ.js +3 -0
- package/dist/web/assets/TeamChatView-Bx44q3WV.css +1 -0
- package/dist/web/assets/TerminalOverlay-C1iP4OS1.js +19 -0
- package/dist/web/assets/TerminalOverlay-DwBiZLwk.css +1 -0
- package/dist/web/assets/TrainingSettingsSection-BDYvI2te.js +1 -0
- package/dist/web/assets/TrainingView-CoCFK6W3.js +5 -0
- package/dist/web/assets/WorkspaceDiffPanel-CMxKQeo7.js +14 -0
- package/dist/web/assets/WorkspaceEnvironmentMenu-B8JJbwIz.js +32 -0
- package/dist/web/assets/WorkspaceEnvironmentMenu-DGIFdG3o.css +1 -0
- package/dist/web/assets/WorkspaceGitDialogs-B4sp9BGn.js +1 -0
- package/dist/web/assets/WorkspaceMonacoEditor-BBqimG5X.js +845 -0
- package/dist/web/assets/WorkspaceMonacoEditor-BwKcXIZw.css +1 -0
- package/dist/web/assets/boxes-DAaDUabq.js +1 -0
- package/dist/web/assets/codicon-ngg6Pgfi.ttf +0 -0
- package/dist/web/assets/css.worker-DBVD8oXr.js +93 -0
- package/dist/web/assets/cssMode-CBF1mieJ.js +1 -0
- package/dist/web/assets/dockerfile-BG73LgW2.js +1 -0
- package/dist/web/assets/editor.worker-CdQrwHl8.js +26 -0
- package/dist/web/assets/git-commit-horizontal-CAickXpN.js +1 -0
- package/dist/web/assets/git-dialogs-BZDqS1eT.css +1 -0
- package/dist/web/assets/html.worker-CwpTb9lJ.js +470 -0
- package/dist/web/assets/htmlMode-2u8OHtWO.js +1 -0
- package/dist/web/assets/index-BdY6A-YN.css +1 -0
- package/dist/web/assets/index-CU2qhUYV.js +195 -0
- package/dist/web/assets/index-Dz2B3-4C.js +1 -0
- package/dist/web/assets/info-CQNTh78o.js +1 -0
- package/dist/web/assets/json.worker-BoL8UZqY.js +58 -0
- package/dist/web/assets/jsonMode-C4CWXViX.js +7 -0
- package/dist/web/assets/lspLanguageFeatures-CBs_BOlB.js +4 -0
- package/dist/web/assets/markdown-BFxVWTOG.js +1 -0
- package/dist/web/assets/monaco.contribution-C1LUxAKf.js +2 -0
- package/dist/web/assets/monaco.contribution-Cpf6dWsh.js +2 -0
- package/dist/web/assets/monaco.contribution-lOXpG2xQ.js +2 -0
- package/dist/web/assets/monaco.contribution-sd3cFkcN.js +2 -0
- package/dist/web/assets/monitor-DsIswrMV.js +1 -0
- package/dist/web/assets/play-CeRw21NV.js +1 -0
- package/dist/web/assets/python-CXYq3BUl.js +1 -0
- package/dist/web/assets/refresh-cw-N5b_6AP5.js +1 -0
- package/dist/web/assets/reply-BSKjZrJg.js +1 -0
- package/dist/web/assets/save-D0oHH1a3.js +1 -0
- package/dist/web/assets/settings-lists-BEg6LMcy.css +1 -0
- package/dist/web/assets/shell-DiJ1NA_G.js +1 -0
- package/dist/web/assets/toggleHighContrast-B7NOMXDY.css +1 -0
- package/dist/web/assets/toggleHighContrast-DRjlcwes.js +62 -0
- package/dist/web/assets/training-model-data-BPrc68VG.js +1 -0
- package/dist/web/assets/ts.worker-BH9nVgjN.js +67718 -0
- package/dist/web/assets/tsMode-x-1A7ZcB.js +11 -0
- package/dist/web/assets/wifi-off-Dt52ofzh.js +1 -0
- package/dist/web/assets/workers-Ciff6Dzi.js +1 -0
- package/dist/web/assets/yaml-CB67Kxnz.js +1 -0
- package/dist/web/connected-apps/github.svg +3 -0
- package/dist/web/connected-apps/google.svg +6 -0
- package/dist/web/connected-apps/linear.svg +3 -0
- package/dist/web/connected-apps/microsoft.svg +6 -0
- package/dist/web/connected-apps/notion.svg +3 -0
- package/dist/web/connected-apps/openpond-mcp.svg +4 -0
- package/dist/web/connected-apps/slack.svg +6 -0
- package/dist/web/connected-apps/x.svg +3 -0
- package/dist/web/favicon-16x16.png +0 -0
- package/dist/web/favicon-32x32.png +0 -0
- package/dist/web/index.html +16 -0
- package/dist/web/openpond-icon.png +0 -0
- package/dist/web/openpond-wordlogo-white.png +0 -0
- package/dist/web/tokens/eth.svg +1 -0
- package/dist/web/tokens/usdc.svg +1 -0
- package/docs/agent-edit-check-status-json.md +132 -0
- package/docs/command-reference.md +695 -0
- package/package.json +84 -0
|
@@ -0,0 +1,892 @@
|
|
|
1
|
+
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
PROJECT_SOURCE_UPLOAD_CONCURRENCY,
|
|
4
|
+
PROJECT_SOURCE_UPLOAD_LIMITS,
|
|
5
|
+
PROJECT_SOURCE_UPLOAD_MAX_BYTES,
|
|
6
|
+
PROJECT_SOURCE_UPLOAD_MAX_FILES,
|
|
7
|
+
PROJECT_SOURCE_UPLOAD_MAX_FILE_BYTES,
|
|
8
|
+
PROJECT_SOURCE_UPLOAD_TRANSPORT,
|
|
9
|
+
buildAgentEditOpenInput,
|
|
10
|
+
buildAgentSourceChecksInput,
|
|
11
|
+
buildAgentSourceConfig,
|
|
12
|
+
buildAgentSourcePolicy,
|
|
13
|
+
buildAgentSourcePublishInput,
|
|
14
|
+
buildAgentUpdateInput,
|
|
15
|
+
buildAgentUpsertInput,
|
|
16
|
+
buildCodingWorkItemBackgroundInput,
|
|
17
|
+
buildCodingWorkItemChatInput,
|
|
18
|
+
buildCodingWorkItemPromotionInput,
|
|
19
|
+
buildProjectUpdateInput,
|
|
20
|
+
buildProjectUpsertInput,
|
|
21
|
+
collectAgentSdkProjectSourceUploadEntries,
|
|
22
|
+
collectProjectSourceUploadEntries,
|
|
23
|
+
mergeProjectSourceUploadEntries,
|
|
24
|
+
parseAgentEntrypointScope,
|
|
25
|
+
parseAgentSourceCheckDispatch,
|
|
26
|
+
parseAgentSourceCheckKind,
|
|
27
|
+
parseAgentSourceMode,
|
|
28
|
+
parseAgentTriggerType,
|
|
29
|
+
parsePositiveLimit,
|
|
30
|
+
parseProjectSourceType,
|
|
31
|
+
resolveLocalAgentSdkCommand,
|
|
32
|
+
resolveProjectSourceUploadBranch
|
|
33
|
+
} from "./chunk-3CC6MH35.js";
|
|
34
|
+
import "./chunk-I6HN3ZGW.js";
|
|
35
|
+
import "./chunk-VQX33YAG.js";
|
|
36
|
+
import "./chunk-LHYK6QO2.js";
|
|
37
|
+
import "./chunk-OG75GMVO.js";
|
|
38
|
+
import "./chunk-BYAPLT37.js";
|
|
39
|
+
import "./chunk-WYDVQOBL.js";
|
|
40
|
+
import {
|
|
41
|
+
parseSandboxWorkflowModeOption,
|
|
42
|
+
resolveSandboxClient,
|
|
43
|
+
runCommand
|
|
44
|
+
} from "./chunk-XSAXENQD.js";
|
|
45
|
+
import "./chunk-5G4E547X.js";
|
|
46
|
+
import {
|
|
47
|
+
optionString,
|
|
48
|
+
optionalJsonObject,
|
|
49
|
+
parseBooleanOption,
|
|
50
|
+
requiredTeamId
|
|
51
|
+
} from "./chunk-3Y4EL3P6.js";
|
|
52
|
+
import "./chunk-UACZUFIA.js";
|
|
53
|
+
|
|
54
|
+
// src/cli/project-agent-formatters.ts
|
|
55
|
+
function isJsonRecord(value) {
|
|
56
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
57
|
+
}
|
|
58
|
+
function optionalStringField(record, key) {
|
|
59
|
+
const value = record?.[key];
|
|
60
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
61
|
+
}
|
|
62
|
+
function optionalStringArrayField(record, key) {
|
|
63
|
+
const value = record?.[key];
|
|
64
|
+
if (!Array.isArray(value)) return [];
|
|
65
|
+
return value.filter((item) => typeof item === "string");
|
|
66
|
+
}
|
|
67
|
+
function optionalRecordField(record, key) {
|
|
68
|
+
const value = record?.[key];
|
|
69
|
+
return isJsonRecord(value) ? value : null;
|
|
70
|
+
}
|
|
71
|
+
function optionalRecordArrayField(record, key) {
|
|
72
|
+
const value = record?.[key];
|
|
73
|
+
if (!Array.isArray(value)) return [];
|
|
74
|
+
return value.filter(isJsonRecord);
|
|
75
|
+
}
|
|
76
|
+
function optionalBooleanField(record, key) {
|
|
77
|
+
const value = record?.[key];
|
|
78
|
+
return typeof value === "boolean" ? value : null;
|
|
79
|
+
}
|
|
80
|
+
function uniqueStrings(values) {
|
|
81
|
+
return [...new Set(values.filter((value) => Boolean(value)))];
|
|
82
|
+
}
|
|
83
|
+
function activityPayloads(activity) {
|
|
84
|
+
return activity.map((item) => item.payload).filter(isJsonRecord);
|
|
85
|
+
}
|
|
86
|
+
function compactDeployPlanFromPayloads(payloads) {
|
|
87
|
+
const payload = payloads.find(
|
|
88
|
+
(item) => optionalStringField(item, "deployPlanStatus") || optionalBooleanField(item, "canDeploy") !== null || optionalBooleanField(item, "canRun") !== null || optionalStringArrayField(item, "blockedReasons").length > 0 || optionalStringArrayField(item, "staleReasons").length > 0
|
|
89
|
+
);
|
|
90
|
+
if (!payload) return null;
|
|
91
|
+
const checks = isJsonRecord(payload.checks) ? payload.checks : null;
|
|
92
|
+
const deployPlan = {};
|
|
93
|
+
const status = optionalStringField(payload, "deployPlanStatus") ?? optionalStringField(payload, "status");
|
|
94
|
+
const canDeploy = optionalBooleanField(payload, "canDeploy");
|
|
95
|
+
const canRun = optionalBooleanField(payload, "canRun");
|
|
96
|
+
const blockedReasons = optionalStringArrayField(payload, "blockedReasons");
|
|
97
|
+
const staleReasons = optionalStringArrayField(payload, "staleReasons");
|
|
98
|
+
const artifactPaths = optionalStringArrayField(payload, "artifactPaths");
|
|
99
|
+
if (status) deployPlan.status = status;
|
|
100
|
+
if (canRun !== null) deployPlan.canRun = canRun;
|
|
101
|
+
if (canDeploy !== null) deployPlan.canDeploy = canDeploy;
|
|
102
|
+
for (const key of ["agentId", "projectId", "sourceRef", "baseSha"]) {
|
|
103
|
+
const value = optionalStringField(payload, key);
|
|
104
|
+
if (value) deployPlan[key] = value;
|
|
105
|
+
}
|
|
106
|
+
if (blockedReasons.length > 0) deployPlan.blockedReasons = blockedReasons;
|
|
107
|
+
if (staleReasons.length > 0) deployPlan.staleReasons = staleReasons;
|
|
108
|
+
if (artifactPaths.length > 0) deployPlan.artifactPaths = artifactPaths;
|
|
109
|
+
if (checks) deployPlan.checks = checks;
|
|
110
|
+
return Object.keys(deployPlan).length > 0 ? deployPlan : null;
|
|
111
|
+
}
|
|
112
|
+
function summarizeSourceCheckStatus(workItem, activity) {
|
|
113
|
+
const payloads = activityPayloads(activity);
|
|
114
|
+
const deployPlan = payloads.map((payload) => payload.deployPlan).find(isJsonRecord) ?? compactDeployPlanFromPayloads(payloads);
|
|
115
|
+
const requestedCheckKind = payloads.map(
|
|
116
|
+
(payload) => optionalStringField(payload, "checkKind") ?? optionalStringField(payload, "requestedCheckKind")
|
|
117
|
+
).find(Boolean) ?? null;
|
|
118
|
+
const traceArtifactRefs = uniqueStrings([
|
|
119
|
+
optionalStringField(workItem, "traceArtifactRef"),
|
|
120
|
+
...payloads.map((payload) => optionalStringField(payload, "traceArtifactRef")),
|
|
121
|
+
...payloads.flatMap(
|
|
122
|
+
(payload) => optionalStringArrayField(payload, "traceArtifactRefs")
|
|
123
|
+
)
|
|
124
|
+
]);
|
|
125
|
+
const evalResultArtifactRefs = uniqueStrings([
|
|
126
|
+
optionalStringField(workItem, "evalResultArtifactRef"),
|
|
127
|
+
...payloads.map(
|
|
128
|
+
(payload) => optionalStringField(payload, "evalResultArtifactRef")
|
|
129
|
+
),
|
|
130
|
+
...payloads.flatMap(
|
|
131
|
+
(payload) => optionalStringArrayField(payload, "evalResultArtifactRefs")
|
|
132
|
+
)
|
|
133
|
+
]);
|
|
134
|
+
const publishBlockers = uniqueStrings([
|
|
135
|
+
...optionalStringArrayField(
|
|
136
|
+
isJsonRecord(deployPlan) ? deployPlan : null,
|
|
137
|
+
"blockedReasons"
|
|
138
|
+
),
|
|
139
|
+
...payloads.flatMap(
|
|
140
|
+
(payload) => optionalStringArrayField(payload, "blockedReasons")
|
|
141
|
+
),
|
|
142
|
+
...payloads.flatMap(
|
|
143
|
+
(payload) => optionalStringArrayField(payload, "publishBlockers")
|
|
144
|
+
)
|
|
145
|
+
]);
|
|
146
|
+
const sourceMaterialization = payloads.map((payload) => optionalRecordField(payload, "sourceMaterialization")).find(Boolean) ?? null;
|
|
147
|
+
const setup = payloads.map((payload) => optionalRecordField(payload, "setup")).find(Boolean) ?? null;
|
|
148
|
+
const sourceUploadMetadata = payloads.map((payload) => optionalRecordField(payload, "sourceUploadMetadata")).find(Boolean) ?? null;
|
|
149
|
+
const policyDiscovery = payloads.map((payload) => optionalRecordField(payload, "policyDiscovery")).find(Boolean) ?? null;
|
|
150
|
+
const discoveredRequiredChecks = uniqueStrings([
|
|
151
|
+
...payloads.flatMap(
|
|
152
|
+
(payload) => optionalStringArrayField(payload, "discoveredRequiredChecks")
|
|
153
|
+
),
|
|
154
|
+
...optionalStringArrayField(policyDiscovery, "requiredChecks")
|
|
155
|
+
]);
|
|
156
|
+
const checkRuns = payloads.flatMap(
|
|
157
|
+
(payload) => optionalRecordArrayField(payload, "checkRuns")
|
|
158
|
+
);
|
|
159
|
+
const validation = payloads.map((payload) => optionalRecordField(payload, "validation")).find(Boolean) ?? null;
|
|
160
|
+
const evalSummary = payloads.map((payload) => optionalRecordField(payload, "eval")).find(Boolean) ?? payloads.map((payload) => optionalRecordField(payload, "evalSummary")).find(Boolean) ?? null;
|
|
161
|
+
const validatorArtifactRefs = uniqueStrings(
|
|
162
|
+
payloads.flatMap(
|
|
163
|
+
(payload) => optionalStringArrayField(payload, "validatorArtifactRefs")
|
|
164
|
+
)
|
|
165
|
+
);
|
|
166
|
+
const patchArtifactRef = payloads.map((payload) => optionalStringField(payload, "patchArtifactRef")).find(Boolean) ?? null;
|
|
167
|
+
const draftSourceRef = payloads.map((payload) => optionalStringField(payload, "draftSourceRef")).find(Boolean) ?? null;
|
|
168
|
+
const finalResultState = payloads.map((payload) => optionalStringField(payload, "finalResultState")).find(Boolean) ?? null;
|
|
169
|
+
return {
|
|
170
|
+
workItemId: workItem.id,
|
|
171
|
+
workItemStatus: optionalStringField(workItem, "status"),
|
|
172
|
+
latestTaskRunId: optionalStringField(workItem, "latestTaskRunId"),
|
|
173
|
+
latestRuntimeId: optionalStringField(workItem, "latestRuntimeId"),
|
|
174
|
+
latestSandboxId: optionalStringField(workItem, "latestSandboxId"),
|
|
175
|
+
sourceMaterialization,
|
|
176
|
+
sourceUploadMetadata,
|
|
177
|
+
setup,
|
|
178
|
+
policyDiscovery,
|
|
179
|
+
discoveredRequiredChecks,
|
|
180
|
+
checkRuns,
|
|
181
|
+
validation,
|
|
182
|
+
eval: evalSummary,
|
|
183
|
+
requestedCheckKind,
|
|
184
|
+
deployPlan,
|
|
185
|
+
traceArtifactRefs,
|
|
186
|
+
evalResultArtifactRefs,
|
|
187
|
+
validatorArtifactRefs,
|
|
188
|
+
patchArtifactRef,
|
|
189
|
+
draftSourceRef,
|
|
190
|
+
finalResultState,
|
|
191
|
+
publishBlockers
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function unsafePublicOutputKey(key) {
|
|
195
|
+
const normalized = key.toLowerCase();
|
|
196
|
+
return normalized.includes("raw") || normalized === "stdout" || normalized === "stderr" || normalized === "log" || normalized === "logs" || normalized === "events" || normalized === "eventstream" || normalized === "fulloutput" || normalized === "processoutput" || normalized === "tracejson" || normalized === "evaljson" || normalized === "evalresultsjson";
|
|
197
|
+
}
|
|
198
|
+
function compactPublicValue(value) {
|
|
199
|
+
if (typeof value === "string") {
|
|
200
|
+
return value.length > 512 ? `${value.slice(0, 512)}...[truncated:${value.length}]` : value;
|
|
201
|
+
}
|
|
202
|
+
if (Array.isArray(value)) {
|
|
203
|
+
return value.slice(0, 50).map((item) => compactPublicValue(item));
|
|
204
|
+
}
|
|
205
|
+
if (isJsonRecord(value)) {
|
|
206
|
+
const output = {};
|
|
207
|
+
for (const [key, item] of Object.entries(value)) {
|
|
208
|
+
if (unsafePublicOutputKey(key)) continue;
|
|
209
|
+
output[key] = compactPublicValue(item);
|
|
210
|
+
}
|
|
211
|
+
return output;
|
|
212
|
+
}
|
|
213
|
+
return value;
|
|
214
|
+
}
|
|
215
|
+
function compactRecordFields(record, fields) {
|
|
216
|
+
if (!record) return null;
|
|
217
|
+
const output = {};
|
|
218
|
+
for (const field of fields) {
|
|
219
|
+
if (!(field in record)) continue;
|
|
220
|
+
output[field] = compactPublicValue(record[field]);
|
|
221
|
+
}
|
|
222
|
+
return Object.keys(output).length > 0 ? output : null;
|
|
223
|
+
}
|
|
224
|
+
function compactWorkItem(workItem) {
|
|
225
|
+
return compactRecordFields(workItem, [
|
|
226
|
+
"id",
|
|
227
|
+
"projectId",
|
|
228
|
+
"assignedAgentId",
|
|
229
|
+
"status",
|
|
230
|
+
"sourceRef",
|
|
231
|
+
"baseSha",
|
|
232
|
+
"latestTaskRunId",
|
|
233
|
+
"latestRuntimeId",
|
|
234
|
+
"latestSandboxId",
|
|
235
|
+
"traceArtifactRef",
|
|
236
|
+
"evalResultArtifactRef",
|
|
237
|
+
"createdAt",
|
|
238
|
+
"updatedAt"
|
|
239
|
+
]) ?? { id: workItem.id };
|
|
240
|
+
}
|
|
241
|
+
function compactArtifact(artifact) {
|
|
242
|
+
return compactRecordFields(artifact, [
|
|
243
|
+
"id",
|
|
244
|
+
"kind",
|
|
245
|
+
"ref",
|
|
246
|
+
"taskRunId",
|
|
247
|
+
"runtimeId",
|
|
248
|
+
"sandboxId",
|
|
249
|
+
"createdAt"
|
|
250
|
+
]) ?? {};
|
|
251
|
+
}
|
|
252
|
+
function compactActivityPayload(payload) {
|
|
253
|
+
return compactRecordFields(payload, [
|
|
254
|
+
"checkKind",
|
|
255
|
+
"requestedCheckKind",
|
|
256
|
+
"deployPlanStatus",
|
|
257
|
+
"canDeploy",
|
|
258
|
+
"canRun",
|
|
259
|
+
"blockedReasons",
|
|
260
|
+
"staleReasons",
|
|
261
|
+
"artifactPaths",
|
|
262
|
+
"agentId",
|
|
263
|
+
"projectId",
|
|
264
|
+
"sourceRef",
|
|
265
|
+
"baseSha",
|
|
266
|
+
"sourceMaterialization",
|
|
267
|
+
"sourceUploadMetadata",
|
|
268
|
+
"setup",
|
|
269
|
+
"policyDiscovery",
|
|
270
|
+
"discoveredRequiredChecks",
|
|
271
|
+
"checkRuns",
|
|
272
|
+
"validation",
|
|
273
|
+
"eval",
|
|
274
|
+
"evalSummary",
|
|
275
|
+
"traceArtifactRef",
|
|
276
|
+
"traceArtifactRefs",
|
|
277
|
+
"evalResultArtifactRef",
|
|
278
|
+
"evalResultArtifactRefs",
|
|
279
|
+
"validatorArtifactRefs",
|
|
280
|
+
"patchArtifactRef",
|
|
281
|
+
"draftSourceRef",
|
|
282
|
+
"finalResultState",
|
|
283
|
+
"publishBlockers"
|
|
284
|
+
]);
|
|
285
|
+
}
|
|
286
|
+
function compactWorkItemActivity(activity) {
|
|
287
|
+
const output = compactRecordFields(activity, [
|
|
288
|
+
"id",
|
|
289
|
+
"type",
|
|
290
|
+
"kind",
|
|
291
|
+
"status",
|
|
292
|
+
"summary",
|
|
293
|
+
"message",
|
|
294
|
+
"createdAt",
|
|
295
|
+
"updatedAt"
|
|
296
|
+
]) ?? { id: activity.id };
|
|
297
|
+
const payload = compactActivityPayload(
|
|
298
|
+
optionalRecordField(activity, "payload")
|
|
299
|
+
);
|
|
300
|
+
if (payload) output.payload = payload;
|
|
301
|
+
return output;
|
|
302
|
+
}
|
|
303
|
+
function compactSourceCheckStatus(status) {
|
|
304
|
+
return compactRecordFields(status, [
|
|
305
|
+
"workItemId",
|
|
306
|
+
"workItemStatus",
|
|
307
|
+
"latestTaskRunId",
|
|
308
|
+
"latestRuntimeId",
|
|
309
|
+
"latestSandboxId",
|
|
310
|
+
"sourceMaterialization",
|
|
311
|
+
"sourceUploadMetadata",
|
|
312
|
+
"setup",
|
|
313
|
+
"policyDiscovery",
|
|
314
|
+
"discoveredRequiredChecks",
|
|
315
|
+
"checkRuns",
|
|
316
|
+
"validation",
|
|
317
|
+
"eval",
|
|
318
|
+
"requestedCheckKind",
|
|
319
|
+
"deployPlan",
|
|
320
|
+
"traceArtifactRefs",
|
|
321
|
+
"evalResultArtifactRefs",
|
|
322
|
+
"validatorArtifactRefs",
|
|
323
|
+
"patchArtifactRef",
|
|
324
|
+
"draftSourceRef",
|
|
325
|
+
"finalResultState",
|
|
326
|
+
"publishBlockers"
|
|
327
|
+
]) ?? { workItemId: optionalStringField(status, "workItemId") ?? "unknown" };
|
|
328
|
+
}
|
|
329
|
+
function compactWorkItemStatusResult(status) {
|
|
330
|
+
const sourceCheckStatus = isJsonRecord(status.sourceCheckStatus) ? status.sourceCheckStatus : summarizeSourceCheckStatus(status.workItem, status.activity);
|
|
331
|
+
return {
|
|
332
|
+
workItem: compactWorkItem(status.workItem),
|
|
333
|
+
activity: status.activity.map((item) => compactWorkItemActivity(item)),
|
|
334
|
+
sourceCheckStatus: compactSourceCheckStatus(sourceCheckStatus)
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function compactBackgroundResult(result) {
|
|
338
|
+
const output = {};
|
|
339
|
+
const workItem = optionalRecordField(result, "workItem");
|
|
340
|
+
if (workItem) output.workItem = compactWorkItem(workItem);
|
|
341
|
+
const activity = optionalRecordField(result, "activity");
|
|
342
|
+
if (activity) {
|
|
343
|
+
output.activity = compactWorkItemActivity(
|
|
344
|
+
activity
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
for (const key of [
|
|
348
|
+
"taskRun",
|
|
349
|
+
"runtime",
|
|
350
|
+
"session",
|
|
351
|
+
"link",
|
|
352
|
+
"toolSummary",
|
|
353
|
+
"accepted",
|
|
354
|
+
"status"
|
|
355
|
+
]) {
|
|
356
|
+
if (key in result) output[key] = compactPublicValue(result[key]);
|
|
357
|
+
}
|
|
358
|
+
return output;
|
|
359
|
+
}
|
|
360
|
+
function formatProjectLine(project) {
|
|
361
|
+
const source = project.gitRepo ? `${project.gitOwner ?? "_"}/${project.gitRepo}` : project.internalRepoPath ?? project.templateRepoUrl ?? project.normalizedSourceIdentity;
|
|
362
|
+
return [
|
|
363
|
+
project.id,
|
|
364
|
+
project.status,
|
|
365
|
+
project.sourceType,
|
|
366
|
+
project.name,
|
|
367
|
+
source
|
|
368
|
+
].join(" ");
|
|
369
|
+
}
|
|
370
|
+
function formatAgentLine(agent) {
|
|
371
|
+
const entrypoint = agent.selectedEntrypoint.name ? `${agent.selectedEntrypoint.scope}:${agent.selectedEntrypoint.name}` : agent.selectedEntrypoint.scope;
|
|
372
|
+
const agentSource = agent.runtimeSource ? [
|
|
373
|
+
agent.runtimeSource.mode,
|
|
374
|
+
agent.runtimeSource.publishedSnapshotName ?? agent.runtimeSource.publishedSnapshotId ?? agent.runtimeSource.sourceRef
|
|
375
|
+
].filter((value) => Boolean(value)).join(":") : "latest_source";
|
|
376
|
+
return [
|
|
377
|
+
agent.id,
|
|
378
|
+
agent.status,
|
|
379
|
+
agent.triggerType,
|
|
380
|
+
agent.defaultWorkflowMode,
|
|
381
|
+
agentSource,
|
|
382
|
+
entrypoint,
|
|
383
|
+
agent.name
|
|
384
|
+
].join(" ");
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// src/cli/agent-source-workflows.ts
|
|
388
|
+
async function runAgentEditWorkflow(client, options, rest) {
|
|
389
|
+
const editCommand = rest[1]?.trim();
|
|
390
|
+
const targetId = rest[2]?.trim();
|
|
391
|
+
const usage = "usage: agent edit <open|chat|activity|background|request-checks|check-status|checkpoint-result|commit-result|pr-result> <id> --team-id <id>";
|
|
392
|
+
const teamId = requiredTeamId(options, usage);
|
|
393
|
+
if (!editCommand || !targetId) {
|
|
394
|
+
throw new Error(usage);
|
|
395
|
+
}
|
|
396
|
+
if (editCommand === "open") {
|
|
397
|
+
const result = await client.agents.openEditWorkItem(
|
|
398
|
+
targetId,
|
|
399
|
+
buildAgentEditOpenInput(targetId, teamId, options)
|
|
400
|
+
);
|
|
401
|
+
console.log(JSON.stringify(result, null, 2));
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
if (editCommand === "chat") {
|
|
405
|
+
const result = await client.workItems.chat(
|
|
406
|
+
targetId,
|
|
407
|
+
buildCodingWorkItemChatInput(teamId, options)
|
|
408
|
+
);
|
|
409
|
+
console.log(JSON.stringify(result, null, 2));
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
if (editCommand === "activity") {
|
|
413
|
+
const activity = await client.workItems.activity(targetId, {
|
|
414
|
+
teamId,
|
|
415
|
+
limit: parsePositiveLimit(options.limit)
|
|
416
|
+
});
|
|
417
|
+
console.log(
|
|
418
|
+
JSON.stringify(
|
|
419
|
+
{ activity: activity.map((item) => compactWorkItemActivity(item)) },
|
|
420
|
+
null,
|
|
421
|
+
2
|
|
422
|
+
)
|
|
423
|
+
);
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
if (editCommand === "background") {
|
|
427
|
+
const result = await client.workItems.handleBackground(
|
|
428
|
+
targetId,
|
|
429
|
+
buildCodingWorkItemBackgroundInput(teamId, options)
|
|
430
|
+
);
|
|
431
|
+
console.log(JSON.stringify(compactBackgroundResult(result), null, 2));
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
if (editCommand === "request-checks") {
|
|
435
|
+
const result = await client.agents.requestSourceChecks(
|
|
436
|
+
targetId,
|
|
437
|
+
buildAgentSourceChecksInput(teamId, options)
|
|
438
|
+
);
|
|
439
|
+
console.log(JSON.stringify(result, null, 2));
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
if (editCommand === "check-status") {
|
|
443
|
+
const status = await client.workItems.status(targetId, {
|
|
444
|
+
teamId,
|
|
445
|
+
limit: parsePositiveLimit(options.limit),
|
|
446
|
+
includeArchived: true
|
|
447
|
+
});
|
|
448
|
+
console.log(JSON.stringify(compactWorkItemStatusResult(status), null, 2));
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
if (editCommand === "checkpoint-result" || editCommand === "commit-result" || editCommand === "pr-result") {
|
|
452
|
+
const input = buildCodingWorkItemPromotionInput(teamId, options);
|
|
453
|
+
const artifact = editCommand === "checkpoint-result" ? await client.workItems.promoteCheckpoint(targetId, input) : editCommand === "commit-result" ? await client.workItems.promoteCommit(targetId, input) : await client.workItems.promotePullRequest(targetId, input);
|
|
454
|
+
console.log(JSON.stringify({ artifact: compactArtifact(artifact) }, null, 2));
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
throw new Error(usage);
|
|
458
|
+
}
|
|
459
|
+
async function runAgentSourceWorkflow(client, options, rest) {
|
|
460
|
+
const sourceCommand = rest[1]?.trim();
|
|
461
|
+
const agentId = rest[2]?.trim();
|
|
462
|
+
const usage = "usage: agent source <deploy-plan|checks|check-status|manifest-snapshots|publish> <id> --team-id <id>";
|
|
463
|
+
const teamId = requiredTeamId(options, usage);
|
|
464
|
+
if (!sourceCommand || !agentId) {
|
|
465
|
+
throw new Error(usage);
|
|
466
|
+
}
|
|
467
|
+
if (sourceCommand === "deploy-plan") {
|
|
468
|
+
const deployPlan = await client.agents.sourceDeployPlan(agentId, {
|
|
469
|
+
teamId
|
|
470
|
+
});
|
|
471
|
+
console.log(JSON.stringify({ deployPlan }, null, 2));
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
if (sourceCommand === "manifest-snapshots") {
|
|
475
|
+
const manifestSnapshots = await client.agents.manifestSnapshots(agentId, {
|
|
476
|
+
teamId,
|
|
477
|
+
limit: parsePositiveLimit(options.limit)
|
|
478
|
+
});
|
|
479
|
+
console.log(JSON.stringify({ manifestSnapshots }, null, 2));
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
if (sourceCommand === "checks") {
|
|
483
|
+
const result = await client.agents.requestSourceChecks(
|
|
484
|
+
agentId,
|
|
485
|
+
buildAgentSourceChecksInput(teamId, options)
|
|
486
|
+
);
|
|
487
|
+
console.log(JSON.stringify(result, null, 2));
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
if (sourceCommand === "check-status") {
|
|
491
|
+
const status = await client.workItems.status(agentId, {
|
|
492
|
+
teamId,
|
|
493
|
+
limit: parsePositiveLimit(options.limit),
|
|
494
|
+
includeArchived: true
|
|
495
|
+
});
|
|
496
|
+
console.log(JSON.stringify(compactWorkItemStatusResult(status), null, 2));
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
if (sourceCommand === "publish") {
|
|
500
|
+
const result = await client.agents.publishSource(
|
|
501
|
+
agentId,
|
|
502
|
+
buildAgentSourcePublishInput(teamId, options)
|
|
503
|
+
);
|
|
504
|
+
console.log(JSON.stringify(result, null, 2));
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
throw new Error(usage);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// src/cli/agent-sdk-local-command.ts
|
|
511
|
+
import path from "node:path";
|
|
512
|
+
var LOCAL_AGENT_SDK_COMMANDS = /* @__PURE__ */ new Set([
|
|
513
|
+
"inspect",
|
|
514
|
+
"build",
|
|
515
|
+
"validate",
|
|
516
|
+
"eval",
|
|
517
|
+
"traces"
|
|
518
|
+
]);
|
|
519
|
+
function shouldDelegateLocalAgentSdkCommand(subcommand, options) {
|
|
520
|
+
if (LOCAL_AGENT_SDK_COMMANDS.has(subcommand)) return true;
|
|
521
|
+
return subcommand === "run" && !optionString(options, "teamId");
|
|
522
|
+
}
|
|
523
|
+
async function runLocalAgentSdkCommand(options, rest) {
|
|
524
|
+
const subcommand = rest[0] || "inspect";
|
|
525
|
+
const cwd = path.resolve(
|
|
526
|
+
optionString(options, "cwd") || optionString(options, "path") || "."
|
|
527
|
+
);
|
|
528
|
+
const args = [subcommand, ...rest.slice(1), "--cwd", cwd];
|
|
529
|
+
if (parseBooleanOption(options.json)) args.push("--json");
|
|
530
|
+
appendForwardedOption(args, options, "input", "input");
|
|
531
|
+
appendForwardedOption(args, options, "inputFile", "input-file");
|
|
532
|
+
const command = resolveLocalAgentSdkCommand(cwd);
|
|
533
|
+
const result = await runCommand(command.command, [...command.args, ...args], {
|
|
534
|
+
cwd,
|
|
535
|
+
inherit: true
|
|
536
|
+
});
|
|
537
|
+
if (result.code !== 0) process.exitCode = result.code ?? 1;
|
|
538
|
+
}
|
|
539
|
+
function appendForwardedOption(args, options, optionKey, cliName) {
|
|
540
|
+
const value = optionString(options, optionKey);
|
|
541
|
+
if (value) args.push(`--${cliName}`, value);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// src/cli/agent-command.ts
|
|
545
|
+
async function runAgentCommand(options, rest) {
|
|
546
|
+
const subcommand = rest[0] || "list";
|
|
547
|
+
if (shouldDelegateLocalAgentSdkCommand(subcommand, options)) {
|
|
548
|
+
await runLocalAgentSdkCommand(options, rest);
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
const client = await resolveSandboxClient(options);
|
|
552
|
+
if (subcommand === "list") {
|
|
553
|
+
const teamId = requiredTeamId(options, "usage: agent list");
|
|
554
|
+
const agents = await client.agents.list({ teamId });
|
|
555
|
+
if (parseBooleanOption(options.json)) {
|
|
556
|
+
console.log(JSON.stringify({ agents }, null, 2));
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
if (agents.length === 0) {
|
|
560
|
+
console.log("no sandbox agents found");
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
for (const agent of agents) {
|
|
564
|
+
console.log(formatAgentLine(agent));
|
|
565
|
+
}
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
if (subcommand === "create" || subcommand === "upsert") {
|
|
569
|
+
const agent = await client.agents.upsert(buildAgentUpsertInput(options));
|
|
570
|
+
console.log(JSON.stringify({ agent }, null, 2));
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
if (subcommand === "get") {
|
|
574
|
+
const agentId = rest[1]?.trim();
|
|
575
|
+
const teamId = requiredTeamId(options, "usage: agent get <agentId>");
|
|
576
|
+
if (!agentId) {
|
|
577
|
+
throw new Error("usage: agent get <agentId> --team-id <id>");
|
|
578
|
+
}
|
|
579
|
+
const agent = await client.agents.get(agentId, { teamId });
|
|
580
|
+
console.log(JSON.stringify({ agent }, null, 2));
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
if (subcommand === "run") {
|
|
584
|
+
const agentId = rest[1]?.trim();
|
|
585
|
+
const teamId = requiredTeamId(options, "usage: agent run <agentId>");
|
|
586
|
+
if (!agentId) {
|
|
587
|
+
throw new Error("usage: agent run <agentId> --team-id <id>");
|
|
588
|
+
}
|
|
589
|
+
const idempotencyKey = optionString(options, "idempotencyKey");
|
|
590
|
+
const conversationId = optionString(options, "conversationId");
|
|
591
|
+
const targetProjectId = optionString(options, "targetProjectId");
|
|
592
|
+
const triggerType = parseAgentTriggerType(options.triggerType);
|
|
593
|
+
const workflowMode = parseSandboxWorkflowModeOption(options.workflowMode);
|
|
594
|
+
const inputObject = optionalJsonObject(options, "input", "input");
|
|
595
|
+
const metadata = optionalJsonObject(options, "metadata", "metadata");
|
|
596
|
+
const agentSourcePolicy = buildAgentSourcePolicy(options);
|
|
597
|
+
const result = await client.agents.run(agentId, {
|
|
598
|
+
teamId,
|
|
599
|
+
...conversationId ? { conversationId } : {},
|
|
600
|
+
...idempotencyKey ? { idempotencyKey } : {},
|
|
601
|
+
...targetProjectId ? { targetProjectId } : {},
|
|
602
|
+
...targetProjectId ? { targetProject: { id: targetProjectId } } : {},
|
|
603
|
+
...triggerType ? { triggerType } : {},
|
|
604
|
+
...workflowMode ? { workflowMode } : {},
|
|
605
|
+
...inputObject ? { input: inputObject } : {},
|
|
606
|
+
...metadata ? { metadata } : {},
|
|
607
|
+
...agentSourcePolicy ? { runtimeSourcePolicy: agentSourcePolicy } : {}
|
|
608
|
+
});
|
|
609
|
+
console.log(JSON.stringify(result, null, 2));
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
if (subcommand === "bind-runtime-source" || subcommand === "bind-source") {
|
|
613
|
+
const agentId = rest[1]?.trim();
|
|
614
|
+
const teamId = requiredTeamId(
|
|
615
|
+
options,
|
|
616
|
+
"usage: agent bind-source <agentId>"
|
|
617
|
+
);
|
|
618
|
+
if (!agentId) {
|
|
619
|
+
throw new Error(
|
|
620
|
+
"usage: agent bind-source <agentId> --team-id <id> --source-mode latest_source|published_snapshot|auto"
|
|
621
|
+
);
|
|
622
|
+
}
|
|
623
|
+
const agentSource = buildAgentSourceConfig(options);
|
|
624
|
+
if (!agentSource?.mode) {
|
|
625
|
+
throw new Error(
|
|
626
|
+
"usage: agent bind-source <agentId> --team-id <id> --source-mode latest_source|published_snapshot|auto"
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
const agent = await client.agents.update(agentId, {
|
|
630
|
+
teamId,
|
|
631
|
+
runtimeSource: agentSource
|
|
632
|
+
});
|
|
633
|
+
console.log(
|
|
634
|
+
JSON.stringify({ agent, agentSource: agent.runtimeSource }, null, 2)
|
|
635
|
+
);
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
if (subcommand === "run-test") {
|
|
639
|
+
const agentId = rest[1]?.trim();
|
|
640
|
+
const teamId = requiredTeamId(options, "usage: agent run-test <agentId>");
|
|
641
|
+
if (!agentId) {
|
|
642
|
+
throw new Error("usage: agent run-test <agentId> --team-id <id>");
|
|
643
|
+
}
|
|
644
|
+
const idempotencyKey = optionString(options, "idempotencyKey");
|
|
645
|
+
const conversationId = optionString(options, "conversationId");
|
|
646
|
+
const targetProjectId = optionString(options, "targetProjectId");
|
|
647
|
+
const inputObject = optionalJsonObject(options, "input", "input");
|
|
648
|
+
const metadata = optionalJsonObject(options, "metadata", "metadata");
|
|
649
|
+
const workflowMode = parseSandboxWorkflowModeOption(options.workflowMode);
|
|
650
|
+
const result = await client.agents.run(agentId, {
|
|
651
|
+
teamId,
|
|
652
|
+
...conversationId ? { conversationId } : {},
|
|
653
|
+
...idempotencyKey ? { idempotencyKey } : {},
|
|
654
|
+
...targetProjectId ? { targetProjectId } : {},
|
|
655
|
+
...targetProjectId ? { targetProject: { id: targetProjectId } } : {},
|
|
656
|
+
...workflowMode ? { workflowMode } : {},
|
|
657
|
+
...inputObject ? { input: inputObject } : {},
|
|
658
|
+
metadata: {
|
|
659
|
+
...metadata ?? {},
|
|
660
|
+
source: "agent_run_test"
|
|
661
|
+
},
|
|
662
|
+
runtimeSourcePolicy: buildAgentSourcePolicy(
|
|
663
|
+
options,
|
|
664
|
+
"diagnostic"
|
|
665
|
+
)
|
|
666
|
+
});
|
|
667
|
+
console.log(
|
|
668
|
+
JSON.stringify(
|
|
669
|
+
{
|
|
670
|
+
resolvedRuntimeSource: result.run.runtimeSource,
|
|
671
|
+
agent: result.agent,
|
|
672
|
+
run: result.run,
|
|
673
|
+
sandbox: result.sandbox ?? null
|
|
674
|
+
},
|
|
675
|
+
null,
|
|
676
|
+
2
|
|
677
|
+
)
|
|
678
|
+
);
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
if (subcommand === "edit") {
|
|
682
|
+
await runAgentEditWorkflow(client, options, rest);
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
if (subcommand === "source") {
|
|
686
|
+
await runAgentSourceWorkflow(client, options, rest);
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
if (subcommand === "update") {
|
|
690
|
+
const agentId = rest[1]?.trim();
|
|
691
|
+
const teamId = requiredTeamId(options, "usage: agent update <agentId>");
|
|
692
|
+
if (!agentId) {
|
|
693
|
+
throw new Error("usage: agent update <agentId> --team-id <id>");
|
|
694
|
+
}
|
|
695
|
+
const agent = await client.agents.update(
|
|
696
|
+
agentId,
|
|
697
|
+
buildAgentUpdateInput(teamId, options)
|
|
698
|
+
);
|
|
699
|
+
console.log(JSON.stringify({ agent }, null, 2));
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
if (subcommand === "archive") {
|
|
703
|
+
const agentId = rest[1]?.trim();
|
|
704
|
+
const teamId = requiredTeamId(options, "usage: agent archive <agentId>");
|
|
705
|
+
if (!agentId) {
|
|
706
|
+
throw new Error("usage: agent archive <agentId> --team-id <id>");
|
|
707
|
+
}
|
|
708
|
+
const agent = await client.agents.archive(agentId, { teamId });
|
|
709
|
+
console.log(JSON.stringify({ agent }, null, 2));
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
throw new Error(
|
|
713
|
+
"usage: agent <inspect|build|validate|eval|traces|list|create|upsert|get|update|run|run-test|bind-source|source|edit|archive> [--team-id <id>] [--project-id <id>] [--name <name>]"
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
// src/cli/project-command.ts
|
|
718
|
+
import path2 from "node:path";
|
|
719
|
+
async function runProjectCommand(options, rest) {
|
|
720
|
+
const subcommand = rest[0] || "list";
|
|
721
|
+
const client = await resolveSandboxClient(options);
|
|
722
|
+
if (subcommand === "list") {
|
|
723
|
+
const teamId = requiredTeamId(options, "usage: project list");
|
|
724
|
+
const projects = await client.projects.list({ teamId });
|
|
725
|
+
if (parseBooleanOption(options.json)) {
|
|
726
|
+
console.log(JSON.stringify({ projects }, null, 2));
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
if (projects.length === 0) {
|
|
730
|
+
console.log("no sandbox projects found");
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
for (const project of projects) {
|
|
734
|
+
console.log(formatProjectLine(project));
|
|
735
|
+
}
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
if (subcommand === "create" || subcommand === "upsert") {
|
|
739
|
+
const project = await client.projects.upsert(
|
|
740
|
+
buildProjectUpsertInput(options)
|
|
741
|
+
);
|
|
742
|
+
console.log(JSON.stringify({ project }, null, 2));
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
if (subcommand === "get") {
|
|
746
|
+
const projectId = rest[1]?.trim();
|
|
747
|
+
const teamId = requiredTeamId(options, "usage: project get <projectId>");
|
|
748
|
+
if (!projectId) {
|
|
749
|
+
throw new Error("usage: project get <projectId> --team-id <id>");
|
|
750
|
+
}
|
|
751
|
+
const project = await client.projects.get(projectId, { teamId });
|
|
752
|
+
console.log(JSON.stringify({ project }, null, 2));
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
if (subcommand === "update") {
|
|
756
|
+
const projectId = rest[1]?.trim();
|
|
757
|
+
const teamId = requiredTeamId(options, "usage: project update <projectId>");
|
|
758
|
+
if (!projectId) {
|
|
759
|
+
throw new Error("usage: project update <projectId> --team-id <id>");
|
|
760
|
+
}
|
|
761
|
+
const project = await client.projects.update(
|
|
762
|
+
projectId,
|
|
763
|
+
buildProjectUpdateInput(teamId, options)
|
|
764
|
+
);
|
|
765
|
+
console.log(JSON.stringify({ project }, null, 2));
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
if (subcommand === "sync") {
|
|
769
|
+
const projectId = rest[1]?.trim();
|
|
770
|
+
const teamId = requiredTeamId(options, "usage: project sync <projectId>");
|
|
771
|
+
if (!projectId) {
|
|
772
|
+
throw new Error("usage: project sync <projectId> --team-id <id>");
|
|
773
|
+
}
|
|
774
|
+
const project = await client.projects.sync(projectId, { teamId });
|
|
775
|
+
console.log(JSON.stringify({ project }, null, 2));
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
if (subcommand === "source-upload" || subcommand === "upload-source") {
|
|
779
|
+
const projectId = rest[1]?.trim();
|
|
780
|
+
const teamId = requiredTeamId(
|
|
781
|
+
options,
|
|
782
|
+
"usage: project source-upload <projectId>"
|
|
783
|
+
);
|
|
784
|
+
if (!projectId) {
|
|
785
|
+
throw new Error(
|
|
786
|
+
"usage: project source-upload <projectId> --team-id <id> [--path <dir>]"
|
|
787
|
+
);
|
|
788
|
+
}
|
|
789
|
+
const projectPath = path2.resolve(optionString(options, "path") || ".");
|
|
790
|
+
const branch = await resolveProjectSourceUploadBranch(projectPath, options);
|
|
791
|
+
const commitMessage = optionString(options, "commitMessage") || optionString(options, "commit-message") || "Upload OpenPond project source";
|
|
792
|
+
const collected = await collectProjectSourceUploadEntries(projectPath);
|
|
793
|
+
const agentSdk = await collectAgentSdkProjectSourceUploadEntries(
|
|
794
|
+
projectPath,
|
|
795
|
+
collected.entries
|
|
796
|
+
);
|
|
797
|
+
const upload = mergeProjectSourceUploadEntries(collected, agentSdk.entries);
|
|
798
|
+
const project = await client.projects.uploadSource(projectId, {
|
|
799
|
+
teamId,
|
|
800
|
+
entries: upload.entries,
|
|
801
|
+
...branch ? { branch } : {},
|
|
802
|
+
commitMessage
|
|
803
|
+
});
|
|
804
|
+
console.log(
|
|
805
|
+
JSON.stringify(
|
|
806
|
+
{
|
|
807
|
+
project,
|
|
808
|
+
uploaded: {
|
|
809
|
+
path: projectPath,
|
|
810
|
+
branch,
|
|
811
|
+
fileCount: upload.fileCount,
|
|
812
|
+
totalBytes: upload.totalBytes,
|
|
813
|
+
limits: upload.limits,
|
|
814
|
+
transport: upload.transport,
|
|
815
|
+
...agentSdk.generatedManifestPath ? {
|
|
816
|
+
agentSdk: {
|
|
817
|
+
generatedManifestPath: agentSdk.generatedManifestPath,
|
|
818
|
+
generatedEntryCount: agentSdk.entries.length,
|
|
819
|
+
synthesizedOpenPondYaml: agentSdk.synthesizedOpenPondYaml,
|
|
820
|
+
uploadMetadataPath: agentSdk.uploadMetadataPath,
|
|
821
|
+
uploadMetadataHash: agentSdk.uploadMetadataHash,
|
|
822
|
+
commands: agentSdk.uploadMetadata?.commands,
|
|
823
|
+
dependencySetup: agentSdk.uploadMetadata?.dependencySetup,
|
|
824
|
+
packageManager: agentSdk.uploadMetadata?.packageManager,
|
|
825
|
+
sourceTreeMode: agentSdk.uploadMetadata?.sourceTreeMode,
|
|
826
|
+
artifactHashes: agentSdk.uploadMetadata?.artifactHashes
|
|
827
|
+
}
|
|
828
|
+
} : {}
|
|
829
|
+
}
|
|
830
|
+
},
|
|
831
|
+
null,
|
|
832
|
+
2
|
|
833
|
+
)
|
|
834
|
+
);
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
if (subcommand === "archive") {
|
|
838
|
+
const projectId = rest[1]?.trim();
|
|
839
|
+
const teamId = requiredTeamId(
|
|
840
|
+
options,
|
|
841
|
+
"usage: project archive <projectId>"
|
|
842
|
+
);
|
|
843
|
+
if (!projectId) {
|
|
844
|
+
throw new Error("usage: project archive <projectId> --team-id <id>");
|
|
845
|
+
}
|
|
846
|
+
const project = await client.projects.archive(projectId, { teamId });
|
|
847
|
+
console.log(JSON.stringify({ project }, null, 2));
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
throw new Error(
|
|
851
|
+
"usage: project <list|create|upsert|get|update|sync|source-upload|archive> [--team-id <id>] [--name <name>]"
|
|
852
|
+
);
|
|
853
|
+
}
|
|
854
|
+
export {
|
|
855
|
+
PROJECT_SOURCE_UPLOAD_CONCURRENCY,
|
|
856
|
+
PROJECT_SOURCE_UPLOAD_LIMITS,
|
|
857
|
+
PROJECT_SOURCE_UPLOAD_MAX_BYTES,
|
|
858
|
+
PROJECT_SOURCE_UPLOAD_MAX_FILES,
|
|
859
|
+
PROJECT_SOURCE_UPLOAD_MAX_FILE_BYTES,
|
|
860
|
+
PROJECT_SOURCE_UPLOAD_TRANSPORT,
|
|
861
|
+
buildAgentEditOpenInput,
|
|
862
|
+
buildAgentSourceChecksInput,
|
|
863
|
+
buildAgentSourceConfig,
|
|
864
|
+
buildAgentSourcePolicy,
|
|
865
|
+
buildAgentSourcePublishInput,
|
|
866
|
+
buildAgentUpdateInput,
|
|
867
|
+
buildAgentUpsertInput,
|
|
868
|
+
buildCodingWorkItemBackgroundInput,
|
|
869
|
+
buildCodingWorkItemChatInput,
|
|
870
|
+
buildCodingWorkItemPromotionInput,
|
|
871
|
+
buildProjectUpdateInput,
|
|
872
|
+
buildProjectUpsertInput,
|
|
873
|
+
collectProjectSourceUploadEntries,
|
|
874
|
+
compactArtifact,
|
|
875
|
+
compactBackgroundResult,
|
|
876
|
+
compactWorkItemActivity,
|
|
877
|
+
compactWorkItemStatusResult,
|
|
878
|
+
formatAgentLine,
|
|
879
|
+
formatProjectLine,
|
|
880
|
+
parseAgentEntrypointScope,
|
|
881
|
+
parseAgentSourceCheckDispatch,
|
|
882
|
+
parseAgentSourceCheckKind,
|
|
883
|
+
parseAgentSourceMode,
|
|
884
|
+
parseAgentTriggerType,
|
|
885
|
+
parsePositiveLimit,
|
|
886
|
+
parseProjectSourceType,
|
|
887
|
+
resolveLocalAgentSdkCommand,
|
|
888
|
+
runAgentCommand,
|
|
889
|
+
runAgentEditWorkflow,
|
|
890
|
+
runAgentSourceWorkflow,
|
|
891
|
+
runProjectCommand
|
|
892
|
+
};
|