stitchkit 0.70.1 → 0.70.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.
Files changed (48) hide show
  1. package/dist/agent-runtime/harness-control.d.ts +2 -0
  2. package/dist/agent-runtime/harness-control.d.ts.map +1 -1
  3. package/dist/agent-runtime/history-chronology.d.ts +19 -0
  4. package/dist/agent-runtime/history-chronology.d.ts.map +1 -0
  5. package/dist/agent-runtime/history.d.ts.map +1 -1
  6. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  7. package/dist/agent-runtime/terminal-status.d.ts.map +1 -1
  8. package/dist/agent-runtime-browser.js +51 -51
  9. package/dist/agent-runtime-coding-tools.js +2 -2
  10. package/dist/agent-runtime-harness.js +60 -16
  11. package/dist/agent-runtime-openrouter.js +2 -2
  12. package/dist/agent-runtime-sqlite-bun.js +5 -5
  13. package/dist/agent-runtime-sqlite-node.js +5 -5
  14. package/dist/agent-runtime.js +110 -110
  15. package/dist/application-grammy.js +2 -2
  16. package/dist/application.js +63 -63
  17. package/dist/browser/live-state.d.ts +126 -0
  18. package/dist/browser/live-state.d.ts.map +1 -0
  19. package/dist/cli.js +5 -5
  20. package/dist/contract/index.js +20 -20
  21. package/dist/declaration.d.ts +4 -0
  22. package/dist/declaration.d.ts.map +1 -1
  23. package/dist/declaration.js +22 -22
  24. package/dist/files.js +3 -3
  25. package/dist/{index-vy5bjy07.js → index-4qfqy0m6.js} +21 -31
  26. package/dist/{index-10gbbbaa.js → index-9sx8tbz2.js} +1 -1
  27. package/dist/{index-4g196jmf.js → index-a01jky8m.js} +69 -7
  28. package/dist/{index-hsabxjz0.js → index-jw81xr75.js} +1 -1
  29. package/dist/index-y2s6h5bf.js +83 -0
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +667 -56
  33. package/dist/node.js +26 -26
  34. package/dist/observability/index.js +22 -22
  35. package/dist/react.js +2 -2
  36. package/dist/realtime/contract.d.ts +30 -11
  37. package/dist/realtime/contract.d.ts.map +1 -1
  38. package/dist/realtime/index.d.ts +1 -1
  39. package/dist/realtime/index.d.ts.map +1 -1
  40. package/dist/server/index.js +79 -79
  41. package/dist/server/multipart.d.ts.map +1 -1
  42. package/dist/testing/surface-conformance.d.ts +4 -2
  43. package/dist/testing/surface-conformance.d.ts.map +1 -1
  44. package/dist/testing.js +122 -111
  45. package/dist/tools.js +57 -57
  46. package/llms-full.txt +224 -4
  47. package/package.json +1 -1
  48. package/dist/index-es0h4w26.js +0 -63
@@ -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';
@@ -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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