@stigmer/session-log 0.0.0-stage → 3.41.1-dev.20261013154405.geb646565b1d9
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/LICENSE +194 -0
- package/catalog.d.ts +18 -0
- package/catalog.d.ts.map +1 -0
- package/catalog.js +60 -0
- package/catalog.js.map +1 -0
- package/fold.d.ts +66 -0
- package/fold.d.ts.map +1 -0
- package/fold.js +755 -0
- package/fold.js.map +1 -0
- package/index.d.ts +6 -0
- package/index.d.ts.map +1 -0
- package/index.js +11 -0
- package/index.js.map +1 -0
- package/package.json +36 -4
- package/render.d.ts +11 -0
- package/render.d.ts.map +1 -0
- package/render.js +101 -0
- package/render.js.map +1 -0
- package/src/catalog.ts +76 -0
- package/src/fold.ts +962 -0
- package/src/index.ts +48 -0
- package/src/render.ts +114 -0
- package/src/todos.ts +90 -0
- package/src/types.ts +310 -0
- package/todos.d.ts +12 -0
- package/todos.d.ts.map +1 -0
- package/todos.js +73 -0
- package/todos.js.map +1 -0
- package/types.d.ts +271 -0
- package/types.d.ts.map +1 -0
- package/types.js +8 -0
- package/types.js.map +1 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Stigmer Contributors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
|
191
|
+
|
|
192
|
+
Except for the contents of the ee/ directory, which are licensed under the
|
|
193
|
+
Stigmer Enterprise License (see ee/LICENSE), everything in this repository
|
|
194
|
+
is licensed under the Apache License, Version 2.0, above.
|
package/catalog.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type SessionEvent } from "@stigmer/protos/ai/stigmer/agentic/session/v1/event_pb";
|
|
2
|
+
/** A SessionEvent oneof case that holds an event. */
|
|
3
|
+
export type SessionEventCase = NonNullable<SessionEvent["event"]["case"]>;
|
|
4
|
+
/** Every event type the contract lands, in declaration order. */
|
|
5
|
+
export declare const SESSION_EVENT_TYPES: ReadonlyArray<string>;
|
|
6
|
+
/** The prefix of Stigmer's own event types, which are not Managed Agents types. */
|
|
7
|
+
export declare const STIGMER_EVENT_TYPE_PREFIX = "stigmer.";
|
|
8
|
+
/** Whether a type is Stigmer's own (stigmer.*) rather than a Managed Agents type. */
|
|
9
|
+
export declare function isStigmerEventType(type: string): boolean;
|
|
10
|
+
/** An event's Managed Agents type string; throws for an event that holds none. */
|
|
11
|
+
export declare function eventTypeOf(event: SessionEvent): string;
|
|
12
|
+
/** The oneof case for a type string; undefined for a type the contract does not land. */
|
|
13
|
+
export declare function eventCaseOf(type: string): SessionEventCase | undefined;
|
|
14
|
+
/** The event's own id ("" when it holds no event). */
|
|
15
|
+
export declare function eventIdOf(event: SessionEvent): string;
|
|
16
|
+
/** The event's processed_at ("" when it holds no event). */
|
|
17
|
+
export declare function processedAtOf(event: SessionEvent): string;
|
|
18
|
+
//# sourceMappingURL=catalog.d.ts.map
|
package/catalog.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["src/catalog.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,wDAAwD,CAAC;AAEhE,qDAAqD;AACrD,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAmB1E,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,MAAM,CAA0B,CAAC;AAEjF,mFAAmF;AACnF,eAAO,MAAM,yBAAyB,aAAa,CAAC;AAEpD,qFAAqF;AACrF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,kFAAkF;AAClF,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAMvD;AAED,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAEtE;AAED,sDAAsD;AACtD,wBAAgB,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAErD;AAED,4DAA4D;AAC5D,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAEzD"}
|
package/catalog.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The session event catalog: each event's Claude Managed Agents type
|
|
3
|
+
* string, read once from the contract (the `event_type` option on every
|
|
4
|
+
* oneof member of SessionEvent, apis/ai/stigmer/agentic/session/v1/
|
|
5
|
+
* event.proto).
|
|
6
|
+
*
|
|
7
|
+
* The type is declared in the proto and nowhere else, so this module maps
|
|
8
|
+
* a oneof case to its option and never restates a type string beside it.
|
|
9
|
+
* Who may write which type is the server's rule and lives there
|
|
10
|
+
* (backend/services/stigmer-server/src/domain/session/events/catalog.ts).
|
|
11
|
+
*
|
|
12
|
+
* Proven by __tests__/catalog.test.ts.
|
|
13
|
+
*/
|
|
14
|
+
import { getOption } from "@bufbuild/protobuf";
|
|
15
|
+
import { event_type } from "@stigmer/protos/ai/stigmer/commons/apiresource/field_options_pb";
|
|
16
|
+
import { SessionEventSchema, } from "@stigmer/protos/ai/stigmer/agentic/session/v1/event_pb";
|
|
17
|
+
const typeByCase = new Map();
|
|
18
|
+
const caseByType = new Map();
|
|
19
|
+
for (const member of SessionEventSchema.oneofs.find((o) => o.name === "event")?.fields ?? []) {
|
|
20
|
+
const type = typeOfMember(member);
|
|
21
|
+
typeByCase.set(member.localName, type);
|
|
22
|
+
caseByType.set(type, member.localName);
|
|
23
|
+
}
|
|
24
|
+
function typeOfMember(member) {
|
|
25
|
+
const type = getOption(member, event_type);
|
|
26
|
+
/* v8 ignore next -- @preserve: every member of the contract declares one (the catalog test pins each type); a member added without it fails here at module load */
|
|
27
|
+
if (type === "") {
|
|
28
|
+
throw new Error(`SessionEvent member '${member.name}' declares no event_type`);
|
|
29
|
+
}
|
|
30
|
+
return type;
|
|
31
|
+
}
|
|
32
|
+
/** Every event type the contract lands, in declaration order. */
|
|
33
|
+
export const SESSION_EVENT_TYPES = [...caseByType.keys()];
|
|
34
|
+
/** The prefix of Stigmer's own event types, which are not Managed Agents types. */
|
|
35
|
+
export const STIGMER_EVENT_TYPE_PREFIX = "stigmer.";
|
|
36
|
+
/** Whether a type is Stigmer's own (stigmer.*) rather than a Managed Agents type. */
|
|
37
|
+
export function isStigmerEventType(type) {
|
|
38
|
+
return type.startsWith(STIGMER_EVENT_TYPE_PREFIX);
|
|
39
|
+
}
|
|
40
|
+
/** An event's Managed Agents type string; throws for an event that holds none. */
|
|
41
|
+
export function eventTypeOf(event) {
|
|
42
|
+
const type = event.event.case === undefined ? undefined : typeByCase.get(event.event.case);
|
|
43
|
+
if (type === undefined) {
|
|
44
|
+
throw new Error("a session event must hold an event");
|
|
45
|
+
}
|
|
46
|
+
return type;
|
|
47
|
+
}
|
|
48
|
+
/** The oneof case for a type string; undefined for a type the contract does not land. */
|
|
49
|
+
export function eventCaseOf(type) {
|
|
50
|
+
return caseByType.get(type);
|
|
51
|
+
}
|
|
52
|
+
/** The event's own id ("" when it holds no event). */
|
|
53
|
+
export function eventIdOf(event) {
|
|
54
|
+
return event.event.case === undefined ? "" : event.event.value.id;
|
|
55
|
+
}
|
|
56
|
+
/** The event's processed_at ("" when it holds no event). */
|
|
57
|
+
export function processedAtOf(event) {
|
|
58
|
+
return event.event.case === undefined ? "" : event.event.value.processedAt;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=catalog.js.map
|
package/catalog.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["src/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,iEAAiE,CAAC;AAC7F,OAAO,EACL,kBAAkB,GAEnB,MAAM,wDAAwD,CAAC;AAKhE,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;AAC7C,MAAM,UAAU,GAAG,IAAI,G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E,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,SAAS,CAAC,KAAmB;IAC3C,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;AACpE,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,aAAa,CAAC,KAAmB;IAC/C,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC;AAC7E,CAAC"}
|
package/fold.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ContentBlock } from "@stigmer/protos/ai/stigmer/agentic/session/v1/event_content_pb";
|
|
2
|
+
import type { SessionEvent } from "@stigmer/protos/ai/stigmer/agentic/session/v1/event_pb";
|
|
3
|
+
import type { StreamSessionEventsResponse } from "@stigmer/protos/ai/stigmer/agentic/session/v1/io_pb";
|
|
4
|
+
import { type SessionFold, type Turn } from "./types.js";
|
|
5
|
+
/** A session's events, folded incrementally (module header). */
|
|
6
|
+
export declare class SessionLog {
|
|
7
|
+
private clock;
|
|
8
|
+
private readonly turns;
|
|
9
|
+
private readonly turnsById;
|
|
10
|
+
private readonly items;
|
|
11
|
+
private readonly setsById;
|
|
12
|
+
private readonly seen;
|
|
13
|
+
private readonly held;
|
|
14
|
+
private readonly pendingOutput;
|
|
15
|
+
private status;
|
|
16
|
+
private lastSeq;
|
|
17
|
+
private snapshotCache?;
|
|
18
|
+
/** Folds stored events, in log order; returns whether anything changed. */
|
|
19
|
+
apply(events: Iterable<SessionEvent>): boolean;
|
|
20
|
+
/** Folds one stream frame: a stored event or a live preview; returns whether anything changed. */
|
|
21
|
+
applyFrame(frame: StreamSessionEventsResponse): boolean;
|
|
22
|
+
/** The fold as it stands: immutable, sharing every object no event touched since the last snapshot. */
|
|
23
|
+
snapshot(): SessionFold;
|
|
24
|
+
private applyEvent;
|
|
25
|
+
private tick;
|
|
26
|
+
/** Marks a node, and every node that holds it, changed. */
|
|
27
|
+
private touch;
|
|
28
|
+
private touchSet;
|
|
29
|
+
private turnOf;
|
|
30
|
+
private threadOf;
|
|
31
|
+
/** The list an event's item belongs to: its thread's, or the turn's primary thread. */
|
|
32
|
+
private ownerOf;
|
|
33
|
+
private addText;
|
|
34
|
+
private addTool;
|
|
35
|
+
private addResult;
|
|
36
|
+
/** Opens a live preview under the id its stored event will carry (module header, "Previews"). */
|
|
37
|
+
private openDraft;
|
|
38
|
+
private whenItem;
|
|
39
|
+
private whenTool;
|
|
40
|
+
private whenSet;
|
|
41
|
+
/** Applies whatever was held for something the log has now shown. */
|
|
42
|
+
private release;
|
|
43
|
+
/** Whether a turn has ended (module header, "A turn's end"). */
|
|
44
|
+
private endedOf;
|
|
45
|
+
private snapTurn;
|
|
46
|
+
private snapItem;
|
|
47
|
+
private snapThread;
|
|
48
|
+
private snapSet;
|
|
49
|
+
}
|
|
50
|
+
/** Folds a whole list of events at once. */
|
|
51
|
+
export declare function foldSession(events: Iterable<SessionEvent>): SessionFold;
|
|
52
|
+
/** A turn of the fold, by its run id. */
|
|
53
|
+
export declare function turnOf(fold: SessionFold, runId: string): Turn | undefined;
|
|
54
|
+
/** The text blocks of a content list, joined. */
|
|
55
|
+
export declare function textOf(content: ReadonlyArray<ContentBlock>): string;
|
|
56
|
+
/**
|
|
57
|
+
* Where a preview belongs, read from the id the runner derived for its
|
|
58
|
+
* stored event (`<run>.<scope>.m<index>` or `.t<index>`; the runner's
|
|
59
|
+
* harness/events/ids.ts): the run, and the thread (`<run>.<scope>`, or ""
|
|
60
|
+
* for the root scope). Undefined for an id of any other shape.
|
|
61
|
+
*/
|
|
62
|
+
export declare function previewPlaceOf(id: string): {
|
|
63
|
+
readonly runId: string;
|
|
64
|
+
readonly threadId: string;
|
|
65
|
+
} | undefined;
|
|
66
|
+
//# sourceMappingURL=fold.d.ts.map
|
package/fold.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fold.d.ts","sourceRoot":"","sources":["src/fold.ts"],"names":[],"mappings":"AAmDA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gEAAgE,CAAC;AACnG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wDAAwD,CAAC;AAC3F,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qDAAqD,CAAC;AAGvG,OAAO,EAWL,KAAK,WAAW,EAWhB,KAAK,IAAI,EAMV,MAAM,YAAY,CAAC;AAyFpB,gEAAgE;AAChE,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiB;IACvC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA8B;IACxD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA8B;IACpD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IACtD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;IAC1C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAc;IACnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA6B;IAC3D,OAAO,CAAC,MAAM,CAAuE;IACrF,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,aAAa,CAAC,CAAwC;IAE9D,2EAA2E;IAC3E,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,OAAO;IAQ9C,kGAAkG;IAClG,UAAU,CAAC,KAAK,EAAE,2BAA2B,G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