@inneranimalmedia/agentsam-sdk 2.6.0 → 2.6.2
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/docs/AUTH_IDENTITY_CONTRACT.md +25 -27
- package/docs/PLATFORM_RUNTIME_EVENTS.md +48 -0
- package/docs/RELEASES.md +7 -7
- package/docs/SDK_WORKER.md +4 -3
- package/docs/SOURCE_ARCHITECTURE.md +58 -0
- package/docs/TEST_TIERS.md +26 -0
- package/migrations/runtime/0001_cli_runtime.sql +298 -0
- package/package.json +28 -7
- package/packages/agentsam-repository/README.md +15 -0
- package/packages/agentsam-repository/package.json +25 -0
- package/packages/agentsam-repository/src/contracts.js +113 -0
- package/packages/agentsam-repository/src/index.js +3 -0
- package/{src/lib → packages/agentsam-repository/src}/merkle/cloudflare-persistence.js +14 -24
- package/{src/lib → packages/agentsam-repository/src}/merkle/index.js +1 -0
- package/{src/lib → packages/agentsam-repository/src}/merkle/persistence.js +6 -4
- package/{src/lib → packages/agentsam-repository/src}/merkle/policy.js +1 -0
- package/packages/agentsam-repository/test/contracts.test.mjs +40 -0
- package/packages/agentsam-repository/test/git-context.test.mjs +24 -0
- package/{test/merkle.test.mjs → packages/agentsam-repository/test/merkle-core.test.mjs} +2 -32
- package/{test → packages/agentsam-repository/test}/merkle-persistence.test.mjs +11 -6
- package/packages/identity/package.json +2 -2
- package/packages/identity/src/contracts/auth-config.js +23 -40
- package/packages/identity/tests/auth-config.test.mjs +14 -23
- package/protocol/COMPANY_REPOSITORY_GRAPH_V1.md +91 -0
- package/protocol/MERKLE_PERSISTENCE_V1.md +2 -0
- package/protocol/MERKLE_PERSISTENCE_V2.md +40 -0
- package/protocol/repository/repository-contract.schema.json +24 -0
- package/protocol/repository/repository-dependency.schema.json +24 -0
- package/protocol/repository/repository-identity.schema.json +17 -0
- package/protocol/rpc/v1/common.proto +16 -0
- package/protocol/rpc/v1/errors.proto +35 -0
- package/protocol/rpc/v1/knowledge.proto +77 -0
- package/services/knowledge/package-lock.json +333 -0
- package/services/knowledge/package.json +5 -1
- package/src/agent/responses-runner.js +63 -35
- package/src/capabilities/repository-snapshot.js +3 -3
- package/src/cli.js +36 -29
- package/src/commands/account-auth.js +1 -1
- package/src/commands/context-economics.js +17 -2
- package/src/commands/context.js +1 -1
- package/src/commands/db.js +20 -3
- package/src/commands/deploy.js +2 -2
- package/src/commands/env.js +90 -0
- package/src/commands/knowledge.js +12 -4
- package/src/commands/merkle-persist.js +30 -11
- package/src/commands/merkle.js +1 -1
- package/src/commands/models.js +123 -65
- package/src/commands/ollama.js +26 -0
- package/src/commands/preferences.js +53 -26
- package/src/commands/providers.js +308 -0
- package/src/commands/shell.js +240 -48
- package/src/commands/tunnel.js +8 -8
- package/src/commands/whoami.js +42 -21
- package/src/errors/contract.js +236 -0
- package/src/errors/diagnostic.js +1 -0
- package/src/errors/index.js +14 -0
- package/src/index.js +13 -1
- package/src/knowledge/service/auth.js +13 -0
- package/src/knowledge/service/grpc-client.js +115 -0
- package/src/knowledge/service/grpc-codec.js +237 -0
- package/src/knowledge/service/grpc-server.js +83 -0
- package/src/knowledge/service/job-engine.js +248 -0
- package/src/knowledge/service/server.js +87 -135
- package/src/knowledge/source.js +1 -1
- package/src/lib/account-session.js +94 -25
- package/src/lib/auth.js +314 -51
- package/src/lib/cli-preferences.js +31 -4
- package/src/lib/core-client.js +75 -30
- package/src/lib/deploy-receipt/index.js +2 -2
- package/src/lib/detect-context.js +14 -16
- package/src/lib/knowledge-docker.js +6 -3
- package/src/lib/local-sessions.js +23 -2
- package/src/lib/local-status.js +1 -1
- package/src/lib/project-config.js +1 -1
- package/src/lib/provider-credentials.js +230 -14
- package/src/lib/slash-commands.js +5 -3
- package/src/local/migrations.js +93 -0
- package/src/local/runtime-store.js +141 -0
- package/src/local/sqlite.js +2 -0
- package/src/local-pty/server.js +113 -51
- package/src/models/discovery.js +327 -0
- package/src/providers/anthropic-messages.js +192 -0
- package/src/providers/cloudflare-chat.js +183 -0
- package/src/providers/factory.js +69 -0
- package/src/providers/gemini-generate-content.js +208 -0
- package/src/providers/index.js +5 -0
- package/src/providers/ollama-chat.js +148 -0
- package/src/providers/openai-responses.js +226 -75
- package/src/repository/index.js +14 -2
- package/src/rpc/generated/common_grpc_pb.js +1 -0
- package/src/rpc/generated/common_pb.js +536 -0
- package/src/rpc/generated/errors_grpc_pb.js +1 -0
- package/src/rpc/generated/errors_pb.js +482 -0
- package/src/rpc/generated/knowledge_grpc_pb.js +135 -0
- package/src/rpc/generated/knowledge_pb.js +2168 -0
- package/src/rpc/generated/package.json +3 -0
- package/src/security/trust-boundary.js +2 -2
- package/src/telemetry/events.js +4 -1
- package/src/ui/cli/activity.js +76 -0
- package/src/ui/cli/compaction.js +15 -0
- package/src/ui/cli/footer.js +39 -0
- package/src/ui/cli/help.js +194 -0
- package/src/ui/cli/plan.js +20 -0
- package/src/ui/cli/runtime-events.js +110 -0
- package/src/ui/cli/waiting.js +16 -0
- package/src/ui/merkle/render.js +1 -1
- package/test/account-session.test.mjs +48 -11
- package/test/apps-scaffold-contract.test.mjs +43 -0
- package/test/cli/preferences-runtime.test.mjs +11 -0
- package/test/cli/runtime-ui.test.mjs +74 -0
- package/test/error-diagnostics.test.mjs +57 -1
- package/test/fixtures/knowledge-rpc-worker.mjs +16 -0
- package/test/integration/cli-help.test.mjs +37 -0
- package/test/integration/knowledge-rpc.test.mjs +112 -0
- package/test/integration/merkle-cli.test.mjs +61 -0
- package/test/integration/merkle-persistence-identity.test.mjs +48 -0
- package/test/integration/provider-env-cli.test.mjs +49 -0
- package/test/integration/provider-factory.test.mjs +197 -0
- package/test/integration/repository-company-graph.test.mjs +90 -0
- package/test/integration/runtime-migrations.test.mjs +82 -0
- package/test/knowledge-service.test.mjs +5 -0
- package/test/knowledge.test.mjs +16 -0
- package/test/live/terminal-transport.live.test.mjs +24 -0
- package/test/local-sessions.test.mjs +7 -1
- package/test/models.test.mjs +101 -4
- package/test/ollama.test.mjs +21 -0
- package/test/portable-context.test.mjs +1 -1
- package/test/provider-credentials.test.mjs +45 -1
- package/test/release-hygiene.test.mjs +13 -5
- package/test/responses-runner.test.mjs +3 -1
- package/test/sdk-worker-contract.test.mjs +5 -1
- package/test/shell.test.mjs +50 -8
- package/test/smoke.mjs +2 -1
- package/test/terminal/local-pty.mock.test.mjs +151 -0
- package/test/whoami-resume.test.mjs +6 -5
- package/src/lib/prompt-byok.js +0 -57
- package/src/lib/save-sdk-token.js +0 -19
- /package/{src/lib → packages/agentsam-repository/src}/git-context.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/diff.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/filemeta.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/git-ignore.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/hash.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/semantic.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/snapshot.js +0 -0
- /package/{src/lib → packages/agentsam-repository/src}/merkle/tree.js +0 -0
|
@@ -8,9 +8,283 @@
|
|
|
8
8
|
"name": "agentsam-knowledge-service-runtime",
|
|
9
9
|
"version": "1.0.0",
|
|
10
10
|
"dependencies": {
|
|
11
|
+
"@grpc/grpc-js": "^1.14.4",
|
|
12
|
+
"google-protobuf": "^3.21.4",
|
|
11
13
|
"typescript": "5.9.3"
|
|
12
14
|
}
|
|
13
15
|
},
|
|
16
|
+
"node_modules/@grpc/grpc-js": {
|
|
17
|
+
"version": "1.14.4",
|
|
18
|
+
"resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.14.4.tgz",
|
|
19
|
+
"integrity": "sha512-k9Dj3DV/itK9D06Y8f190Qgop7/Ui+D0njFV3LHMPwPT75DpXLQohE9Wmz0QElrJnzsjB7KPWiKJbOl7IPDArQ==",
|
|
20
|
+
"license": "Apache-2.0",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@grpc/proto-loader": "^0.8.0",
|
|
23
|
+
"@js-sdsl/ordered-map": "^4.4.2"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=12.10.0"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"node_modules/@grpc/proto-loader": {
|
|
30
|
+
"version": "0.8.1",
|
|
31
|
+
"resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.8.1.tgz",
|
|
32
|
+
"integrity": "sha512-wtF6h+DY6M3YaDBPAmvuuA6jV8Sif9MjtOI5euKFWRgCDl5PeDpPsHR9u2l6St5ceY8AZgoNDww5+HvEsXFsGg==",
|
|
33
|
+
"license": "Apache-2.0",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"lodash.camelcase": "^4.3.0",
|
|
36
|
+
"long": "^5.0.0",
|
|
37
|
+
"protobufjs": "^7.5.5",
|
|
38
|
+
"yargs": "^17.7.2"
|
|
39
|
+
},
|
|
40
|
+
"bin": {
|
|
41
|
+
"proto-loader-gen-types": "build/bin/proto-loader-gen-types.js"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=6"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"node_modules/@js-sdsl/ordered-map": {
|
|
48
|
+
"version": "4.4.2",
|
|
49
|
+
"resolved": "https://registry.npmjs.org/@js-sdsl/ordered-map/-/ordered-map-4.4.2.tgz",
|
|
50
|
+
"integrity": "sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw==",
|
|
51
|
+
"license": "MIT",
|
|
52
|
+
"funding": {
|
|
53
|
+
"type": "opencollective",
|
|
54
|
+
"url": "https://opencollective.com/js-sdsl"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"node_modules/@protobufjs/aspromise": {
|
|
58
|
+
"version": "1.1.2",
|
|
59
|
+
"resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz",
|
|
60
|
+
"integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==",
|
|
61
|
+
"license": "BSD-3-Clause"
|
|
62
|
+
},
|
|
63
|
+
"node_modules/@protobufjs/base64": {
|
|
64
|
+
"version": "1.1.2",
|
|
65
|
+
"resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz",
|
|
66
|
+
"integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==",
|
|
67
|
+
"license": "BSD-3-Clause"
|
|
68
|
+
},
|
|
69
|
+
"node_modules/@protobufjs/codegen": {
|
|
70
|
+
"version": "2.0.5",
|
|
71
|
+
"resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.5.tgz",
|
|
72
|
+
"integrity": "sha512-zgXFLzW3Ap33e6d0Wlj4MGIm6Ce8O89n/apUaGNB/jx+hw+ruWEp7EwGUshdLKVRCxZW12fp9r40E1mQrf/34g==",
|
|
73
|
+
"license": "BSD-3-Clause"
|
|
74
|
+
},
|
|
75
|
+
"node_modules/@protobufjs/eventemitter": {
|
|
76
|
+
"version": "1.1.1",
|
|
77
|
+
"resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.1.tgz",
|
|
78
|
+
"integrity": "sha512-vW1GmwMZNnL+gMRaovlh9yZX74kc+TTU3FObkkurpMaRtBfLP3ldjS9KQWlwZgraRE0+dheEEoAxdzcJQ8eXZg==",
|
|
79
|
+
"license": "BSD-3-Clause"
|
|
80
|
+
},
|
|
81
|
+
"node_modules/@protobufjs/fetch": {
|
|
82
|
+
"version": "1.1.1",
|
|
83
|
+
"resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.1.tgz",
|
|
84
|
+
"integrity": "sha512-GpptLrs57adMSuHi3VNj0mAF8dwh36LMaYF6XyJ6JMWlVsc+t42tm1HSEDmOs3A8fC9yyeisgLhsTVQokOZ0zw==",
|
|
85
|
+
"license": "BSD-3-Clause",
|
|
86
|
+
"dependencies": {
|
|
87
|
+
"@protobufjs/aspromise": "^1.1.1"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"node_modules/@protobufjs/float": {
|
|
91
|
+
"version": "1.0.2",
|
|
92
|
+
"resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz",
|
|
93
|
+
"integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==",
|
|
94
|
+
"license": "BSD-3-Clause"
|
|
95
|
+
},
|
|
96
|
+
"node_modules/@protobufjs/path": {
|
|
97
|
+
"version": "1.1.2",
|
|
98
|
+
"resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz",
|
|
99
|
+
"integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==",
|
|
100
|
+
"license": "BSD-3-Clause"
|
|
101
|
+
},
|
|
102
|
+
"node_modules/@protobufjs/pool": {
|
|
103
|
+
"version": "1.1.0",
|
|
104
|
+
"resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz",
|
|
105
|
+
"integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==",
|
|
106
|
+
"license": "BSD-3-Clause"
|
|
107
|
+
},
|
|
108
|
+
"node_modules/@protobufjs/utf8": {
|
|
109
|
+
"version": "1.1.2",
|
|
110
|
+
"resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.2.tgz",
|
|
111
|
+
"integrity": "sha512-b1UQwcEZ4yCnMCD8DAL1VlbvBJE9/IX4FTIp7BG1xYpf29SLazLSrqUkj4w7Y5y7cCVP6E5tcqqcI0xemPkHug==",
|
|
112
|
+
"license": "BSD-3-Clause"
|
|
113
|
+
},
|
|
114
|
+
"node_modules/@types/node": {
|
|
115
|
+
"version": "22.20.3",
|
|
116
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.3.tgz",
|
|
117
|
+
"integrity": "sha512-DZmzkmwHzXrLPAXPyKNDzlIwMMUZCVacoD25ywdy5YTKGbOx/2ld+Q38Im2zJ0vBuZP5Prd3VZutKZyXwkOS8A==",
|
|
118
|
+
"license": "MIT",
|
|
119
|
+
"dependencies": {
|
|
120
|
+
"undici-types": "~6.21.0"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"node_modules/ansi-regex": {
|
|
124
|
+
"version": "5.0.1",
|
|
125
|
+
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
|
126
|
+
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
|
127
|
+
"license": "MIT",
|
|
128
|
+
"engines": {
|
|
129
|
+
"node": ">=8"
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"node_modules/ansi-styles": {
|
|
133
|
+
"version": "4.3.0",
|
|
134
|
+
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
|
135
|
+
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
|
136
|
+
"license": "MIT",
|
|
137
|
+
"dependencies": {
|
|
138
|
+
"color-convert": "^2.0.1"
|
|
139
|
+
},
|
|
140
|
+
"engines": {
|
|
141
|
+
"node": ">=8"
|
|
142
|
+
},
|
|
143
|
+
"funding": {
|
|
144
|
+
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
"node_modules/cliui": {
|
|
148
|
+
"version": "8.0.1",
|
|
149
|
+
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
|
|
150
|
+
"integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==",
|
|
151
|
+
"license": "ISC",
|
|
152
|
+
"dependencies": {
|
|
153
|
+
"string-width": "^4.2.0",
|
|
154
|
+
"strip-ansi": "^6.0.1",
|
|
155
|
+
"wrap-ansi": "^7.0.0"
|
|
156
|
+
},
|
|
157
|
+
"engines": {
|
|
158
|
+
"node": ">=12"
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
"node_modules/color-convert": {
|
|
162
|
+
"version": "2.0.1",
|
|
163
|
+
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
|
164
|
+
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
|
165
|
+
"license": "MIT",
|
|
166
|
+
"dependencies": {
|
|
167
|
+
"color-name": "~1.1.4"
|
|
168
|
+
},
|
|
169
|
+
"engines": {
|
|
170
|
+
"node": ">=7.0.0"
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
"node_modules/color-name": {
|
|
174
|
+
"version": "1.1.4",
|
|
175
|
+
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
|
176
|
+
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
|
177
|
+
"license": "MIT"
|
|
178
|
+
},
|
|
179
|
+
"node_modules/emoji-regex": {
|
|
180
|
+
"version": "8.0.0",
|
|
181
|
+
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
|
182
|
+
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
|
|
183
|
+
"license": "MIT"
|
|
184
|
+
},
|
|
185
|
+
"node_modules/escalade": {
|
|
186
|
+
"version": "3.2.0",
|
|
187
|
+
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
|
|
188
|
+
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
|
|
189
|
+
"license": "MIT",
|
|
190
|
+
"engines": {
|
|
191
|
+
"node": ">=6"
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
"node_modules/get-caller-file": {
|
|
195
|
+
"version": "2.0.5",
|
|
196
|
+
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
|
|
197
|
+
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
|
|
198
|
+
"license": "ISC",
|
|
199
|
+
"engines": {
|
|
200
|
+
"node": "6.* || 8.* || >= 10.*"
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
"node_modules/google-protobuf": {
|
|
204
|
+
"version": "3.21.4",
|
|
205
|
+
"resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.21.4.tgz",
|
|
206
|
+
"integrity": "sha512-MnG7N936zcKTco4Jd2PX2U96Kf9PxygAPKBug+74LHzmHXmceN16MmRcdgZv+DGef/S9YvQAfRsNCn4cjf9yyQ==",
|
|
207
|
+
"license": "(BSD-3-Clause AND Apache-2.0)"
|
|
208
|
+
},
|
|
209
|
+
"node_modules/is-fullwidth-code-point": {
|
|
210
|
+
"version": "3.0.0",
|
|
211
|
+
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
|
|
212
|
+
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
|
|
213
|
+
"license": "MIT",
|
|
214
|
+
"engines": {
|
|
215
|
+
"node": ">=8"
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
"node_modules/lodash.camelcase": {
|
|
219
|
+
"version": "4.3.0",
|
|
220
|
+
"resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz",
|
|
221
|
+
"integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==",
|
|
222
|
+
"license": "MIT"
|
|
223
|
+
},
|
|
224
|
+
"node_modules/long": {
|
|
225
|
+
"version": "5.3.2",
|
|
226
|
+
"resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",
|
|
227
|
+
"integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==",
|
|
228
|
+
"license": "Apache-2.0"
|
|
229
|
+
},
|
|
230
|
+
"node_modules/protobufjs": {
|
|
231
|
+
"version": "7.6.6",
|
|
232
|
+
"resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.6.6.tgz",
|
|
233
|
+
"integrity": "sha512-dYDWdjSl5RNb7SgPxGQcRU+GtvP7s2fpkrY0r432PcOIaZ0/rBcxEZnQN67iJhFuQiVw754JDoPruPCNdGsbjg==",
|
|
234
|
+
"hasInstallScript": true,
|
|
235
|
+
"license": "BSD-3-Clause",
|
|
236
|
+
"dependencies": {
|
|
237
|
+
"@protobufjs/aspromise": "^1.1.2",
|
|
238
|
+
"@protobufjs/base64": "^1.1.2",
|
|
239
|
+
"@protobufjs/codegen": "^2.0.5",
|
|
240
|
+
"@protobufjs/eventemitter": "^1.1.1",
|
|
241
|
+
"@protobufjs/fetch": "^1.1.1",
|
|
242
|
+
"@protobufjs/float": "^1.0.2",
|
|
243
|
+
"@protobufjs/path": "^1.1.2",
|
|
244
|
+
"@protobufjs/pool": "^1.1.0",
|
|
245
|
+
"@protobufjs/utf8": "^1.1.1",
|
|
246
|
+
"@types/node": ">=13.7.0",
|
|
247
|
+
"long": "^5.3.2"
|
|
248
|
+
},
|
|
249
|
+
"engines": {
|
|
250
|
+
"node": ">=12.0.0"
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
"node_modules/require-directory": {
|
|
254
|
+
"version": "2.1.1",
|
|
255
|
+
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
|
256
|
+
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
|
|
257
|
+
"license": "MIT",
|
|
258
|
+
"engines": {
|
|
259
|
+
"node": ">=0.10.0"
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
"node_modules/string-width": {
|
|
263
|
+
"version": "4.2.3",
|
|
264
|
+
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
|
265
|
+
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
|
|
266
|
+
"license": "MIT",
|
|
267
|
+
"dependencies": {
|
|
268
|
+
"emoji-regex": "^8.0.0",
|
|
269
|
+
"is-fullwidth-code-point": "^3.0.0",
|
|
270
|
+
"strip-ansi": "^6.0.1"
|
|
271
|
+
},
|
|
272
|
+
"engines": {
|
|
273
|
+
"node": ">=8"
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
"node_modules/strip-ansi": {
|
|
277
|
+
"version": "6.0.1",
|
|
278
|
+
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
|
|
279
|
+
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
|
|
280
|
+
"license": "MIT",
|
|
281
|
+
"dependencies": {
|
|
282
|
+
"ansi-regex": "^5.0.1"
|
|
283
|
+
},
|
|
284
|
+
"engines": {
|
|
285
|
+
"node": ">=8"
|
|
286
|
+
}
|
|
287
|
+
},
|
|
14
288
|
"node_modules/typescript": {
|
|
15
289
|
"version": "5.9.3",
|
|
16
290
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
|
@@ -23,6 +297,65 @@
|
|
|
23
297
|
"engines": {
|
|
24
298
|
"node": ">=14.17"
|
|
25
299
|
}
|
|
300
|
+
},
|
|
301
|
+
"node_modules/undici-types": {
|
|
302
|
+
"version": "6.21.0",
|
|
303
|
+
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
|
304
|
+
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
|
305
|
+
"license": "MIT"
|
|
306
|
+
},
|
|
307
|
+
"node_modules/wrap-ansi": {
|
|
308
|
+
"version": "7.0.0",
|
|
309
|
+
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
|
|
310
|
+
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
|
|
311
|
+
"license": "MIT",
|
|
312
|
+
"dependencies": {
|
|
313
|
+
"ansi-styles": "^4.0.0",
|
|
314
|
+
"string-width": "^4.1.0",
|
|
315
|
+
"strip-ansi": "^6.0.0"
|
|
316
|
+
},
|
|
317
|
+
"engines": {
|
|
318
|
+
"node": ">=10"
|
|
319
|
+
},
|
|
320
|
+
"funding": {
|
|
321
|
+
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
"node_modules/y18n": {
|
|
325
|
+
"version": "5.0.8",
|
|
326
|
+
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
|
327
|
+
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
|
|
328
|
+
"license": "ISC",
|
|
329
|
+
"engines": {
|
|
330
|
+
"node": ">=10"
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
"node_modules/yargs": {
|
|
334
|
+
"version": "17.7.3",
|
|
335
|
+
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.3.tgz",
|
|
336
|
+
"integrity": "sha512-GZtjxm/J/4TSxuL3FNYjCmLktBTnIw/rVmKSIyKeYAZpmJB2ig9VauCC5xsa82GNKVKDAqpOn3KVzNt0zmrU0g==",
|
|
337
|
+
"license": "MIT",
|
|
338
|
+
"dependencies": {
|
|
339
|
+
"cliui": "^8.0.1",
|
|
340
|
+
"escalade": "^3.1.1",
|
|
341
|
+
"get-caller-file": "^2.0.5",
|
|
342
|
+
"require-directory": "^2.1.1",
|
|
343
|
+
"string-width": "^4.2.3",
|
|
344
|
+
"y18n": "^5.0.5",
|
|
345
|
+
"yargs-parser": "^21.1.1"
|
|
346
|
+
},
|
|
347
|
+
"engines": {
|
|
348
|
+
"node": ">=12"
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
"node_modules/yargs-parser": {
|
|
352
|
+
"version": "21.1.1",
|
|
353
|
+
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
|
|
354
|
+
"integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
|
|
355
|
+
"license": "ISC",
|
|
356
|
+
"engines": {
|
|
357
|
+
"node": ">=12"
|
|
358
|
+
}
|
|
26
359
|
}
|
|
27
360
|
}
|
|
28
361
|
}
|
|
@@ -23,9 +23,11 @@ function userMessage(text) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function modelBudget(record) {
|
|
26
|
+
const windowTokens = Number(record?.context_window);
|
|
27
|
+
if (!Number.isFinite(windowTokens) || windowTokens <= 0) return null;
|
|
26
28
|
const policy = record.context_policy || {};
|
|
27
29
|
return createContextBudget({
|
|
28
|
-
windowTokens
|
|
30
|
+
windowTokens,
|
|
29
31
|
targetInputTokens: policy.target_input_tokens,
|
|
30
32
|
compactAtTokens: policy.compact_at_tokens,
|
|
31
33
|
interveneAtTokens: policy.intervene_at_tokens,
|
|
@@ -102,6 +104,7 @@ function boundedToolOutput(value, callId, maxChars) {
|
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
function toolResultCharBudget(activeTokens, budget) {
|
|
107
|
+
if (!budget) return 48_000;
|
|
105
108
|
if (!Number.isFinite(activeTokens) || activeTokens < 0) return budget.maxToolResultChars;
|
|
106
109
|
const reserveTokens = 4_000;
|
|
107
110
|
const headroomTokens = Math.max(256, budget.maxNormalInputTokens - Math.ceil(activeTokens) - reserveTokens);
|
|
@@ -110,12 +113,13 @@ function toolResultCharBudget(activeTokens, budget) {
|
|
|
110
113
|
|
|
111
114
|
function projectedInputTokens({ instructions, input, toolSurface, priorActiveTokens, budget }) {
|
|
112
115
|
const inputChars = typeof input === 'string' ? input.length : JSON.stringify(input ?? '').length;
|
|
113
|
-
const
|
|
116
|
+
const charsPerToken = budget?.charsPerToken || 4;
|
|
117
|
+
const newTokens = estimateContextTokens(String(instructions || '').length + inputChars + toolSurface.receipt.hydrated_schema_chars, charsPerToken);
|
|
114
118
|
return Math.max(newTokens, Number.isFinite(priorActiveTokens) ? Math.ceil(priorActiveTokens) + newTokens : newTokens);
|
|
115
119
|
}
|
|
116
120
|
|
|
117
121
|
function assertEconomicPreflight(projectedTokens, budget, allowOverride) {
|
|
118
|
-
if (allowOverride) return;
|
|
122
|
+
if (!budget || allowOverride) return;
|
|
119
123
|
if (budget.pricingThresholdTokens != null && projectedTokens > budget.pricingThresholdTokens) {
|
|
120
124
|
throw new Error(`context_preflight_pricing_threshold:${projectedTokens}>${budget.pricingThresholdTokens}`);
|
|
121
125
|
}
|
|
@@ -130,46 +134,56 @@ export async function runResponsesAgent(options = {}) {
|
|
|
130
134
|
const cwd = path.resolve(options.cwd || process.cwd());
|
|
131
135
|
const objective = clean(options.prompt);
|
|
132
136
|
if (!objective) throw new TypeError('prompt is required');
|
|
133
|
-
const record = getModelRecord(options.model);
|
|
137
|
+
const record = options.modelRecord || getModelRecord(options.model);
|
|
134
138
|
if (!record) throw new RangeError(`unknown model: ${options.model}`);
|
|
135
|
-
const reasoningEffort = clean(options.reasoningEffort || '
|
|
139
|
+
const reasoningEffort = clean(options.reasoningEffort || 'auto');
|
|
136
140
|
const serviceTier = clean(options.serviceTier || 'default');
|
|
137
141
|
const budget = modelBudget(record);
|
|
138
|
-
const instructionSet = options.instructions == null ? compileAgentInstructions(cwd, { maxChars: budget
|
|
142
|
+
const instructionSet = options.instructions == null ? compileAgentInstructions(cwd, { maxChars: budget?.maxSystemChars || 48_000 }) : null;
|
|
139
143
|
const instructions = options.instructions == null ? instructionSet.content : String(options.instructions);
|
|
140
144
|
const toolSurface = buildAgentToolSurface(options.capabilityAdapter, objective, options);
|
|
141
145
|
const emit = options.emit;
|
|
142
146
|
const runId = options.runId;
|
|
143
147
|
event(emit, 'tool.search', toolSurface.receipt, runId);
|
|
144
148
|
|
|
145
|
-
let previousResponseId = clean(options.previousResponseId) || null;
|
|
149
|
+
let previousResponseId = clean(options.previousResponseId || options.previousProviderState?.previous_response_id) || null;
|
|
150
|
+
let providerState = options.previousProviderState && typeof options.previousProviderState === 'object'
|
|
151
|
+
? structuredClone(options.previousProviderState)
|
|
152
|
+
: previousResponseId ? { previous_response_id: previousResponseId } : null;
|
|
146
153
|
let priorActiveTokens = options.previousUsageSnapshot?.current_context?.input_tokens;
|
|
147
154
|
let input = objective;
|
|
148
155
|
let compacted = null;
|
|
149
156
|
let projected = projectedInputTokens({ instructions, input, toolSurface, priorActiveTokens, budget });
|
|
150
157
|
|
|
151
|
-
if (projected >= budget.compactAtTokens &&
|
|
158
|
+
if (budget && projected >= budget.compactAtTokens && providerState && options.autoCompact !== false && typeof provider.compact === 'function') {
|
|
152
159
|
compacted = await provider.compact({
|
|
153
160
|
model: record.provider_model_id,
|
|
161
|
+
modelRecord: record,
|
|
154
162
|
previousResponseId,
|
|
163
|
+
providerState,
|
|
155
164
|
instructions,
|
|
156
165
|
promptCacheKey: options.promptCacheKey,
|
|
166
|
+
tokensBefore: Number.isFinite(priorActiveTokens) ? priorActiveTokens : projected,
|
|
157
167
|
emit,
|
|
158
168
|
runId,
|
|
159
169
|
});
|
|
160
|
-
input = [...
|
|
161
|
-
|
|
170
|
+
if (Array.isArray(compacted.output) && compacted.output.length) input = [...compacted.output, userMessage(objective)];
|
|
171
|
+
providerState = compacted.provider_state || null;
|
|
172
|
+
previousResponseId = clean(providerState?.previous_response_id) || null;
|
|
162
173
|
priorActiveTokens = null;
|
|
163
174
|
projected = projectedInputTokens({ instructions, input, toolSurface, priorActiveTokens, budget });
|
|
164
175
|
}
|
|
165
176
|
|
|
166
177
|
assertEconomicPreflight(projected, budget, options.allowEconomicOverride === true);
|
|
167
|
-
const pressure = assessContextUsage(projected, budget);
|
|
178
|
+
const pressure = budget ? assessContextUsage(projected, budget) : null;
|
|
179
|
+
const declaredMaxOutput = Number(record.max_output_tokens);
|
|
168
180
|
const maxOutputTokens = Number.isInteger(options.maxOutputTokens) && options.maxOutputTokens > 0
|
|
169
|
-
? Math.min(options.maxOutputTokens,
|
|
170
|
-
: Math.min(32_768,
|
|
171
|
-
const projectedCost =
|
|
172
|
-
|
|
181
|
+
? (Number.isFinite(declaredMaxOutput) && declaredMaxOutput > 0 ? Math.min(options.maxOutputTokens, declaredMaxOutput) : options.maxOutputTokens)
|
|
182
|
+
: (Number.isFinite(declaredMaxOutput) && declaredMaxOutput > 0 ? Math.min(32_768, declaredMaxOutput) : 16_384);
|
|
183
|
+
const projectedCost = record.pricing
|
|
184
|
+
? calculateModelCost(record, { input_tokens: projected, output_tokens: maxOutputTokens }, { serviceTier })
|
|
185
|
+
: null;
|
|
186
|
+
if (Number.isFinite(options.maxCallCostUsd) && projectedCost && projectedCost.total_usd > options.maxCallCostUsd) {
|
|
173
187
|
throw new Error(`projected_call_cost_exceeds_budget:${projectedCost.total_usd.toFixed(6)}>${Number(options.maxCallCostUsd).toFixed(6)}`);
|
|
174
188
|
}
|
|
175
189
|
const preflight = Object.freeze({
|
|
@@ -178,9 +192,9 @@ export async function runResponsesAgent(options = {}) {
|
|
|
178
192
|
service_tier: serviceTier,
|
|
179
193
|
estimated_input_tokens: projected,
|
|
180
194
|
max_output_tokens: maxOutputTokens,
|
|
181
|
-
projected_max_call_cost_usd: projectedCost
|
|
182
|
-
pricing_threshold_tokens: budget
|
|
183
|
-
tokens_until_pricing_threshold: pressure
|
|
195
|
+
projected_max_call_cost_usd: projectedCost?.total_usd ?? null,
|
|
196
|
+
pricing_threshold_tokens: budget?.pricingThresholdTokens ?? null,
|
|
197
|
+
tokens_until_pricing_threshold: pressure?.tokensUntilPricingThreshold ?? null,
|
|
184
198
|
compacted_before_turn: Boolean(compacted),
|
|
185
199
|
estimate_kind: 'local',
|
|
186
200
|
});
|
|
@@ -191,32 +205,40 @@ export async function runResponsesAgent(options = {}) {
|
|
|
191
205
|
event(emit, 'context.snapshot', {
|
|
192
206
|
estimate_kind: 'local',
|
|
193
207
|
estimated_input_tokens: projected,
|
|
194
|
-
window_tokens: budget
|
|
195
|
-
utilization_ratio: pressure
|
|
196
|
-
pricing_threshold_tokens: budget
|
|
197
|
-
tokens_until_pricing_threshold: pressure
|
|
198
|
-
pressure: pressure
|
|
199
|
-
projected_max_call_cost_usd: projectedCost
|
|
208
|
+
window_tokens: budget?.windowTokens ?? null,
|
|
209
|
+
utilization_ratio: pressure?.utilizationRatio ?? null,
|
|
210
|
+
pricing_threshold_tokens: budget?.pricingThresholdTokens ?? null,
|
|
211
|
+
tokens_until_pricing_threshold: pressure?.tokensUntilPricingThreshold ?? null,
|
|
212
|
+
pressure: pressure?.stage ?? 'unknown',
|
|
213
|
+
projected_max_call_cost_usd: projectedCost?.total_usd ?? null,
|
|
200
214
|
tool_surface: toolSurface.receipt,
|
|
201
215
|
}, runId);
|
|
202
216
|
|
|
203
217
|
let cumulativeUsage = options.cumulativeUsage || null;
|
|
204
218
|
let totalCostUsd = 0;
|
|
219
|
+
const costBreakdownUsd = { input: 0, cached_input: 0, cache_write: 0, output: 0 };
|
|
220
|
+
const accumulateCost = (cost) => {
|
|
221
|
+
totalCostUsd += Number(cost?.total_usd || 0);
|
|
222
|
+
for (const key of Object.keys(costBreakdownUsd)) costBreakdownUsd[key] += Number(cost?.components_usd?.[key] || 0);
|
|
223
|
+
};
|
|
205
224
|
let response = await provider.create({
|
|
206
225
|
model: record.provider_model_id,
|
|
226
|
+
modelRecord: record,
|
|
207
227
|
input,
|
|
208
228
|
instructions,
|
|
209
229
|
reasoningEffort,
|
|
210
230
|
serviceTier,
|
|
211
231
|
tools: toolSurface.tools,
|
|
212
232
|
previousResponseId: previousResponseId || undefined,
|
|
233
|
+
providerState,
|
|
213
234
|
maxOutputTokens,
|
|
214
235
|
promptCacheKey: options.promptCacheKey,
|
|
215
236
|
cumulativeUsage,
|
|
216
237
|
emit,
|
|
217
238
|
runId,
|
|
218
239
|
});
|
|
219
|
-
|
|
240
|
+
accumulateCost(response.cost);
|
|
241
|
+
providerState = response.provider_state || (response.response_id ? { previous_response_id: response.response_id } : providerState);
|
|
220
242
|
cumulativeUsage = response.usage_snapshot?.cumulative || cumulativeUsage;
|
|
221
243
|
|
|
222
244
|
const toolReceipts = [];
|
|
@@ -275,6 +297,8 @@ export async function runResponsesAgent(options = {}) {
|
|
|
275
297
|
response = await provider.continueWithToolOutputs({
|
|
276
298
|
model: record.provider_model_id,
|
|
277
299
|
previousResponseId: response.response_id,
|
|
300
|
+
providerState: response.provider_state || providerState,
|
|
301
|
+
modelRecord: record,
|
|
278
302
|
toolOutputs: outputs,
|
|
279
303
|
instructions,
|
|
280
304
|
reasoningEffort,
|
|
@@ -286,21 +310,22 @@ export async function runResponsesAgent(options = {}) {
|
|
|
286
310
|
emit,
|
|
287
311
|
runId,
|
|
288
312
|
});
|
|
289
|
-
|
|
313
|
+
accumulateCost(response.cost);
|
|
314
|
+
providerState = response.provider_state || (response.response_id ? { previous_response_id: response.response_id } : providerState);
|
|
290
315
|
cumulativeUsage = response.usage_snapshot?.cumulative || cumulativeUsage;
|
|
291
316
|
}
|
|
292
317
|
|
|
293
318
|
const active = response.usage_snapshot?.current_context?.input_tokens ?? 0;
|
|
294
|
-
const finalPressure = assessContextUsage(active, budget);
|
|
319
|
+
const finalPressure = budget ? assessContextUsage(active, budget) : null;
|
|
295
320
|
event(emit, 'context.snapshot', {
|
|
296
321
|
estimate_kind: 'provider',
|
|
297
322
|
active_input_tokens: active,
|
|
298
|
-
window_tokens: budget
|
|
299
|
-
utilization_ratio: finalPressure
|
|
300
|
-
pricing_threshold_tokens: budget
|
|
301
|
-
tokens_until_pricing_threshold: finalPressure
|
|
302
|
-
pressure: finalPressure
|
|
303
|
-
compact_before_next_turn: finalPressure
|
|
323
|
+
window_tokens: budget?.windowTokens ?? null,
|
|
324
|
+
utilization_ratio: finalPressure?.utilizationRatio ?? null,
|
|
325
|
+
pricing_threshold_tokens: budget?.pricingThresholdTokens ?? null,
|
|
326
|
+
tokens_until_pricing_threshold: finalPressure?.tokensUntilPricingThreshold ?? null,
|
|
327
|
+
pressure: finalPressure?.stage ?? 'unknown',
|
|
328
|
+
compact_before_next_turn: finalPressure?.shouldCompact ?? false,
|
|
304
329
|
}, runId);
|
|
305
330
|
|
|
306
331
|
return Object.freeze({
|
|
@@ -313,13 +338,16 @@ export async function runResponsesAgent(options = {}) {
|
|
|
313
338
|
usage_snapshot: response.usage_snapshot,
|
|
314
339
|
cumulative_usage: cumulativeUsage,
|
|
315
340
|
total_cost_usd: totalCostUsd,
|
|
341
|
+
cost_breakdown_usd: Object.freeze({ ...costBreakdownUsd }),
|
|
316
342
|
tool_surface: toolSurface.receipt,
|
|
317
343
|
tool_receipts: Object.freeze(toolReceipts),
|
|
318
344
|
compacted_before_turn: Boolean(compacted),
|
|
345
|
+
provider_state: providerState,
|
|
319
346
|
continuation: Object.freeze({
|
|
320
|
-
previous_response_id: response.response_id,
|
|
347
|
+
previous_response_id: response.response_id || providerState?.previous_response_id || null,
|
|
348
|
+
provider_state: providerState,
|
|
321
349
|
usage_snapshot: response.usage_snapshot,
|
|
322
|
-
compact_before_next_turn: finalPressure
|
|
350
|
+
compact_before_next_turn: finalPressure?.shouldCompact ?? false,
|
|
323
351
|
}),
|
|
324
352
|
});
|
|
325
353
|
}
|
|
@@ -4,10 +4,10 @@ import { execFile } from 'node:child_process';
|
|
|
4
4
|
import { promisify } from 'node:util';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { createHash } from 'node:crypto';
|
|
7
|
-
import { resolveGitContext } from '
|
|
7
|
+
import { resolveGitContext } from '../../packages/agentsam-repository/src/git-context.js';
|
|
8
8
|
import { getRepositoryId, tryReadProjectConfig } from '../lib/project-config.js';
|
|
9
|
-
import { buildMerkleTree } from '
|
|
10
|
-
import { gitIgnoredPaths } from '
|
|
9
|
+
import { buildMerkleTree } from '../../packages/agentsam-repository/src/merkle/index.js';
|
|
10
|
+
import { gitIgnoredPaths } from '../../packages/agentsam-repository/src/merkle/git-ignore.js';
|
|
11
11
|
import { analyzeExecutionBoundaries } from '../indexing/execution-boundary.js';
|
|
12
12
|
import { showLatestDeployReceipt } from '../lib/deploy-receipt/index.js';
|
|
13
13
|
import { CONFIG_PATH, canonical, readConfig, scopeKey } from '../knowledge/config.js';
|