stitchkit 0.70.1 → 0.70.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.
- package/dist/agent-runtime/harness-control.d.ts +2 -0
- package/dist/agent-runtime/harness-control.d.ts.map +1 -1
- package/dist/agent-runtime/history-chronology.d.ts +19 -0
- package/dist/agent-runtime/history-chronology.d.ts.map +1 -0
- package/dist/agent-runtime/history.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-status.d.ts.map +1 -1
- package/dist/agent-runtime-browser.js +51 -51
- package/dist/agent-runtime-coding-tools.js +2 -2
- package/dist/agent-runtime-harness.js +60 -16
- package/dist/agent-runtime-openrouter.js +2 -2
- package/dist/agent-runtime-sqlite-bun.js +5 -5
- package/dist/agent-runtime-sqlite-node.js +5 -5
- package/dist/agent-runtime.js +110 -110
- package/dist/application-grammy.js +2 -2
- package/dist/application.js +63 -63
- package/dist/browser/live-state.d.ts +126 -0
- package/dist/browser/live-state.d.ts.map +1 -0
- package/dist/cli.js +5 -5
- package/dist/contract/index.js +20 -20
- package/dist/declaration.d.ts +4 -0
- package/dist/declaration.d.ts.map +1 -1
- package/dist/declaration.js +22 -22
- package/dist/files.js +3 -3
- package/dist/{index-4g196jmf.js → index-1zxf9x2z.js} +112 -20
- package/dist/{index-vy5bjy07.js → index-4qfqy0m6.js} +21 -31
- package/dist/{index-10gbbbaa.js → index-9sx8tbz2.js} +1 -1
- package/dist/{index-hsabxjz0.js → index-jw81xr75.js} +1 -1
- package/dist/index-y2s6h5bf.js +83 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +667 -56
- package/dist/node.js +26 -26
- package/dist/observability/index.js +22 -22
- package/dist/react.js +2 -2
- package/dist/realtime/contract.d.ts +30 -11
- package/dist/realtime/contract.d.ts.map +1 -1
- package/dist/realtime/index.d.ts +1 -1
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/error-dispatch.d.ts +13 -0
- package/dist/server/error-dispatch.d.ts.map +1 -0
- package/dist/server/index.js +79 -79
- package/dist/server/multipart.d.ts.map +1 -1
- package/dist/server/types.d.ts +6 -0
- package/dist/server/types.d.ts.map +1 -1
- package/dist/testing/surface-conformance.d.ts +4 -2
- package/dist/testing/surface-conformance.d.ts.map +1 -1
- package/dist/testing.js +122 -111
- package/dist/tools.js +57 -57
- package/llms-full.txt +237 -9
- package/package.json +1 -1
- package/dist/index-es0h4w26.js +0 -63
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
advanceToolChronology,
|
|
2
3
|
assistantStatus,
|
|
4
|
+
canProjectToolChronology,
|
|
5
|
+
createToolChronology,
|
|
3
6
|
isAssistantHistoryEvidence,
|
|
4
7
|
isCompleteAgentHistoryTurn
|
|
5
|
-
} from "./index-
|
|
8
|
+
} from "./index-y2s6h5bf.js";
|
|
6
9
|
import {
|
|
7
10
|
createBoundedSinkManager
|
|
8
11
|
} from "./index-a59da114.js";
|
|
@@ -511,42 +514,20 @@ function interruptedSystemNote(message) {
|
|
|
511
514
|
rendered.add("control");
|
|
512
515
|
return { text: `[interrupted] partial response: ${text}`, rendered };
|
|
513
516
|
}
|
|
514
|
-
function completeToolChronology(message) {
|
|
515
|
-
const pending = new Set;
|
|
516
|
-
const completed = new Set;
|
|
517
|
-
let resultsStarted = false;
|
|
518
|
-
for (const part of message.parts) {
|
|
519
|
-
if (part.type === "tool-call") {
|
|
520
|
-
if (resultsStarted && pending.size > 0)
|
|
521
|
-
return false;
|
|
522
|
-
if (pending.size === 0)
|
|
523
|
-
resultsStarted = false;
|
|
524
|
-
if (pending.has(part.callId) || completed.has(part.callId))
|
|
525
|
-
return false;
|
|
526
|
-
pending.add(part.callId);
|
|
527
|
-
}
|
|
528
|
-
if (part.type === "tool-result") {
|
|
529
|
-
if (!pending.delete(part.callId))
|
|
530
|
-
return false;
|
|
531
|
-
completed.add(part.callId);
|
|
532
|
-
resultsStarted = true;
|
|
533
|
-
}
|
|
534
|
-
if (part.type === "tool-approval-request") {
|
|
535
|
-
if (!pending.delete(part.callId))
|
|
536
|
-
return false;
|
|
537
|
-
completed.add(part.callId);
|
|
538
|
-
resultsStarted = true;
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
return pending.size === 0;
|
|
542
|
-
}
|
|
543
517
|
async function projectAgentHistoryDetailed(messages, options = {}) {
|
|
544
518
|
const projected = [];
|
|
545
519
|
const system = [];
|
|
546
520
|
const decisions = [];
|
|
547
521
|
const interruptedRule = options.interruptedAssistant ?? "assistant-marked";
|
|
548
522
|
let observedUser = false;
|
|
523
|
+
let chronology = createToolChronology();
|
|
524
|
+
let conversationId;
|
|
549
525
|
for (const message of messages) {
|
|
526
|
+
if (message.conversationId !== conversationId) {
|
|
527
|
+
conversationId = message.conversationId;
|
|
528
|
+
chronology = createToolChronology();
|
|
529
|
+
observedUser = false;
|
|
530
|
+
}
|
|
550
531
|
if (message.role === "assistant" && !isAssistantHistoryEvidence(message.status, options.evidencePolicy)) {
|
|
551
532
|
decisions.push(decide(message, "omitted", message.status === "superseded" ? "superseded" : "draft-or-failed"));
|
|
552
533
|
continue;
|
|
@@ -557,6 +538,8 @@ async function projectAgentHistoryDetailed(messages, options = {}) {
|
|
|
557
538
|
}
|
|
558
539
|
if (message.role === "user") {
|
|
559
540
|
const user = await userMessage(message, options);
|
|
541
|
+
if (chronology.pending === 0)
|
|
542
|
+
chronology = createToolChronology();
|
|
560
543
|
observedUser = true;
|
|
561
544
|
if (user.message) {
|
|
562
545
|
projected.push(user.message);
|
|
@@ -598,7 +581,8 @@ async function projectAgentHistoryDetailed(messages, options = {}) {
|
|
|
598
581
|
}
|
|
599
582
|
continue;
|
|
600
583
|
}
|
|
601
|
-
|
|
584
|
+
const nextChronology = advanceToolChronology(chronology, message.parts);
|
|
585
|
+
if (!nextChronology || !canProjectToolChronology(nextChronology)) {
|
|
602
586
|
if (options.incompleteToolTurn === "error") {
|
|
603
587
|
throw new Error(`Assistant message ${message.id} has incomplete tool chronology`);
|
|
604
588
|
}
|
|
@@ -606,6 +590,7 @@ async function projectAgentHistoryDetailed(messages, options = {}) {
|
|
|
606
590
|
continue;
|
|
607
591
|
}
|
|
608
592
|
const assistant = assistantMessages(message, interrupted ? "interrupted" : message.status === "failed" ? "failed" : undefined);
|
|
593
|
+
chronology = nextChronology;
|
|
609
594
|
projected.push(...assistant.messages);
|
|
610
595
|
decisions.push(assistant.messages.length > 0 ? decide(message, "projected", "projected", assistant.rendered) : decide(message, "omitted", "empty"));
|
|
611
596
|
}
|
|
@@ -1477,6 +1462,11 @@ function createRunExecutor(dependencies) {
|
|
|
1477
1462
|
evidencePolicy: config.history.evidencePolicy
|
|
1478
1463
|
}
|
|
1479
1464
|
});
|
|
1465
|
+
for (const decision of detailed.decisions) {
|
|
1466
|
+
if (decision.action === "omitted" && run.inputMessageIds.includes(decision.messageId) && source.messages.some((message) => message.id === decision.messageId && message.role === "tool")) {
|
|
1467
|
+
throw new Error(`Invalid approval continuation ${decision.messageId}: ${decision.reason}`);
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1480
1470
|
carriedSystem = detailed.system;
|
|
1481
1471
|
return [...detailed.messages];
|
|
1482
1472
|
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// src/agent-runtime/history-chronology.ts
|
|
2
|
+
function createToolChronology() {
|
|
3
|
+
return { calls: new Map, approvals: new Map, pending: 0, resultsStarted: false };
|
|
4
|
+
}
|
|
5
|
+
function advanceToolChronology(previous, parts) {
|
|
6
|
+
const calls = new Map(previous.calls);
|
|
7
|
+
const approvals = new Map(previous.approvals);
|
|
8
|
+
let { pending, resultsStarted } = previous;
|
|
9
|
+
for (const part of parts) {
|
|
10
|
+
if (part.type === "tool-call") {
|
|
11
|
+
if (calls.has(part.callId) || resultsStarted && pending > 0)
|
|
12
|
+
return;
|
|
13
|
+
if (pending === 0)
|
|
14
|
+
resultsStarted = false;
|
|
15
|
+
calls.set(part.callId, { toolName: part.toolName, phase: "called" });
|
|
16
|
+
pending += 1;
|
|
17
|
+
} else if (part.type === "tool-approval-request") {
|
|
18
|
+
const call = calls.get(part.callId);
|
|
19
|
+
if (call?.phase !== "called" || approvals.has(part.approvalId))
|
|
20
|
+
return;
|
|
21
|
+
approvals.set(part.approvalId, part.callId);
|
|
22
|
+
calls.set(part.callId, { ...call, phase: "requested" });
|
|
23
|
+
} else if (part.type === "tool-approval-response") {
|
|
24
|
+
const callId = approvals.get(part.approvalId);
|
|
25
|
+
const call = callId === undefined ? undefined : calls.get(callId);
|
|
26
|
+
if (callId === undefined || !call || call.phase !== "requested")
|
|
27
|
+
return;
|
|
28
|
+
calls.set(callId, { ...call, phase: part.approved ? "approved" : "denied" });
|
|
29
|
+
} else if (part.type === "tool-result") {
|
|
30
|
+
const call = calls.get(part.callId);
|
|
31
|
+
if (!call || call.toolName !== part.toolName || call.phase === "result" || call.phase === "requested" || call.phase === "denied" && part.outcome === "success")
|
|
32
|
+
return;
|
|
33
|
+
calls.set(part.callId, { ...call, phase: "result" });
|
|
34
|
+
pending -= 1;
|
|
35
|
+
resultsStarted = true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return { calls, approvals, pending, resultsStarted };
|
|
39
|
+
}
|
|
40
|
+
function canProjectToolChronology(state) {
|
|
41
|
+
return [...state.calls.values()].every(({ phase }) => phase !== "called");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/agent-runtime/terminal-status.ts
|
|
45
|
+
function isSpeakableAssistantStatus(status) {
|
|
46
|
+
return status === "completed" || status === "interrupted" || status === "committed";
|
|
47
|
+
}
|
|
48
|
+
function isAssistantHistoryEvidence(status, policy) {
|
|
49
|
+
return isSpeakableAssistantStatus(status) || status === "failed" && policy?.failedAssistant === "assistant-marked";
|
|
50
|
+
}
|
|
51
|
+
function isCompleteAgentHistoryTurn(messages, policy) {
|
|
52
|
+
if (messages[0]?.role !== "user")
|
|
53
|
+
return false;
|
|
54
|
+
let chronology = createToolChronology();
|
|
55
|
+
let assistantCount = 0;
|
|
56
|
+
for (const message of messages) {
|
|
57
|
+
if (message.role === "assistant") {
|
|
58
|
+
if (!isAssistantHistoryEvidence(message.status, policy))
|
|
59
|
+
return false;
|
|
60
|
+
assistantCount += 1;
|
|
61
|
+
}
|
|
62
|
+
const next = advanceToolChronology(chronology, message.parts);
|
|
63
|
+
if (!next)
|
|
64
|
+
return false;
|
|
65
|
+
chronology = next;
|
|
66
|
+
}
|
|
67
|
+
return assistantCount > 0 && chronology.pending === 0;
|
|
68
|
+
}
|
|
69
|
+
function assistantStatus(reason) {
|
|
70
|
+
if (reason === "success" || reason === "policy_stop" || reason === "provider_stop") {
|
|
71
|
+
return "completed";
|
|
72
|
+
}
|
|
73
|
+
if (reason === "superseded")
|
|
74
|
+
return "superseded";
|
|
75
|
+
if (reason === "absorbed")
|
|
76
|
+
return "superseded";
|
|
77
|
+
if (reason === "interrupted" || reason === "cancelled" || reason === "shutdown") {
|
|
78
|
+
return "interrupted";
|
|
79
|
+
}
|
|
80
|
+
return "failed";
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { createToolChronology, advanceToolChronology, canProjectToolChronology, isAssistantHistoryEvidence, isCompleteAgentHistoryTurn, assistantStatus };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { type ClientConfig, type ClientContract, type ClientFetch, type ClientRegistryValue, type ContractClientConfig, contractEndpointMatchers, createClient, createClients, createScopedClients, createScopedUrlBuilders, createUrlBuilder, createUrlBuilders, type PathPrefixArgs, type RegistryScope, type ScopeClientConfigs, type ScopedClientRegistry, type ScopedUrlBuilderRegistry, type UrlBuilderConfig, } from './browser/client.js';
|
|
2
2
|
export { ApiError, type ApiEvent, type ApiEventListener, type ConfiguredHttpClient, createHttpClient, type HeaderProvider, type HttpClient, type HttpClientConfig, type RequestOptions, type UnauthorizedMatcher, } from './browser/http.js';
|
|
3
|
+
export { createLiveStateController, type LiveStateController, type LiveStateControllerConfig, type LiveStateControllerError, type LiveStateControllerSnapshot, type LiveStateControllerStatus, LiveStateControllerStatusSchema, type LiveStateEventDecision, type LiveStatePhase, LiveStatePhaseSchema, type LiveStateSource, type LiveStateSourceOpenInput, type LiveStateSourceOpenResult, type LiveStateStopReason, LiveStateStopReasonSchema, type LiveStateSubscriberError, } from './browser/live-state.js';
|
|
3
4
|
export type { BindRealtimeClientOptions, BoundRealtimeClient, RealtimeClient, RealtimeClientOptions, RealtimeClientTransport, SocketEventMap, SocketIOClient, SocketIOClientConfig, SocketIOClientPeerLoaders, } from './browser/socket-io.js';
|
|
4
5
|
export { bindRealtimeClient, createRealtimeClient, createSocketIOClient, } from './browser/socket-io.js';
|
|
5
6
|
export { type ParseNDJSONOptions, type ParseSSEOptions, parseNDJSON, parseSSE, } from './browser/stream.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,wBAAwB,EACxB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,QAAQ,EACR,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,mBAAmB,GACzB,MAAM,gBAAgB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