@asaidimu/utils-workspace 6.5.11 → 6.6.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/index.d.mts +304 -116
- package/index.d.ts +304 -116
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IndexDefinition, SchemaDefinition, SchemaChange, DataTransform } from '@asaidimu/anansi';
|
|
2
2
|
import { QueryFilter, PaginationOptions } from '@asaidimu/query';
|
|
3
|
-
import { GenerateContentParameters, GoogleGenAI, GenerateContentResponse
|
|
3
|
+
import { GenerateContentParameters, GoogleGenAI, GenerateContentResponse } from '@google/genai';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Buffers write operations across one or more stores and commits them atomically.
|
|
@@ -551,12 +551,85 @@ interface CheckpointSessionState {
|
|
|
551
551
|
* TODO items, or incomplete reasoning paths.
|
|
552
552
|
*/
|
|
553
553
|
unresolved: string[];
|
|
554
|
+
/**
|
|
555
|
+
* Derived realizations, synthesized understanding, reframings, or emergent patterns discovered during the conversation.
|
|
556
|
+
* These are not raw facts or decisions, but higher-level understanding gained by either party.
|
|
557
|
+
*/
|
|
558
|
+
insights?: string[];
|
|
554
559
|
/**
|
|
555
560
|
* Additional continuity information that does not cleanly fit
|
|
556
561
|
* other state categories but is required for faithful continuation.
|
|
557
562
|
*/
|
|
558
563
|
notes?: string[];
|
|
564
|
+
/**
|
|
565
|
+
* External documents, URLs, or resources brought into the conversation
|
|
566
|
+
* by the user or referenced during reasoning.
|
|
567
|
+
*
|
|
568
|
+
* These are inputs — things that informed the conversation.
|
|
569
|
+
*/
|
|
570
|
+
references?: ContextReference[];
|
|
571
|
+
/**
|
|
572
|
+
* Artifacts produced during the conversation.
|
|
573
|
+
*
|
|
574
|
+
* These are outputs — things created as a result of the conversation.
|
|
575
|
+
* The record is keyed by artifact key and description
|
|
576
|
+
*/
|
|
577
|
+
artifacts?: ContextReference[];
|
|
559
578
|
}
|
|
579
|
+
interface ContextReference {
|
|
580
|
+
/**
|
|
581
|
+
* The Key of the injected context item this reference points to.
|
|
582
|
+
* Allows the runtime to re-inject the same context when resuming.
|
|
583
|
+
* Omitted for external references that were never part of the Context system.
|
|
584
|
+
*/
|
|
585
|
+
key?: string;
|
|
586
|
+
label: string;
|
|
587
|
+
/** Why this reference matters for conversational continuity. */
|
|
588
|
+
description: string;
|
|
589
|
+
}
|
|
590
|
+
interface Artifact extends BaseContentBlock<"artifact"> {
|
|
591
|
+
/** Unique lookup key for this artifact entry. */
|
|
592
|
+
key: string;
|
|
593
|
+
/** Incrementing number representing edits to the same artifact ID. */
|
|
594
|
+
version: number;
|
|
595
|
+
/** Short human-readable label. */
|
|
596
|
+
label: string;
|
|
597
|
+
/**
|
|
598
|
+
* What was produced, its structure, and its role in the conversation.
|
|
599
|
+
* Enough detail to understand the artifact without re-reading it.
|
|
600
|
+
*/
|
|
601
|
+
description: string;
|
|
602
|
+
/** The contents of the artifact. */
|
|
603
|
+
content: TextContextContent;
|
|
604
|
+
/**
|
|
605
|
+
* Current status of this artifact.
|
|
606
|
+
* - complete: finished and accepted
|
|
607
|
+
* - draft: produced but pending refinement
|
|
608
|
+
*/
|
|
609
|
+
status: "complete" | "draft";
|
|
610
|
+
/**
|
|
611
|
+
* UTC timestamp of when this artifact was produced.
|
|
612
|
+
* Preserves ordering when multiple artifacts exist.
|
|
613
|
+
*/
|
|
614
|
+
created?: Timestamp;
|
|
615
|
+
/**
|
|
616
|
+
* UTC timestamp of when this artifact was updated.
|
|
617
|
+
* Preserves ordering when multiple artifacts exist.
|
|
618
|
+
*/
|
|
619
|
+
updated?: Timestamp;
|
|
620
|
+
}
|
|
621
|
+
type ArtifactPatchFormat = "unified-diff";
|
|
622
|
+
interface ArtifactPatch {
|
|
623
|
+
format: ArtifactPatchFormat;
|
|
624
|
+
value: string;
|
|
625
|
+
}
|
|
626
|
+
type ArtifactUpdate = Pick<Artifact, "key" | "status"> & ({
|
|
627
|
+
content: TextContextContent;
|
|
628
|
+
patch?: never;
|
|
629
|
+
} | {
|
|
630
|
+
patch: ArtifactPatch;
|
|
631
|
+
content?: never;
|
|
632
|
+
});
|
|
560
633
|
|
|
561
634
|
/**
|
|
562
635
|
* This file contains the primary domain models, data structures, and command types
|
|
@@ -734,6 +807,12 @@ interface BlobRecord {
|
|
|
734
807
|
interface BaseContentBlock<BlockType extends string> {
|
|
735
808
|
/** Unique identifier for the specific content block instance. */
|
|
736
809
|
id: UUID;
|
|
810
|
+
/**
|
|
811
|
+
* Stable unique identifier for this artifact across the conversation.
|
|
812
|
+
* Allows lineage references from other artifacts.
|
|
813
|
+
* Different from id in that it is designed for model consumption
|
|
814
|
+
*/
|
|
815
|
+
key?: string;
|
|
737
816
|
/** Discriminator used to determine the shape and rendering of the block. */
|
|
738
817
|
type: BlockType;
|
|
739
818
|
/** Extensible key-value store for block-specific properties. */
|
|
@@ -963,39 +1042,63 @@ interface Preference {
|
|
|
963
1042
|
/** UTC timestamp of when this preference was established or last updated. */
|
|
964
1043
|
timestamp: Timestamp;
|
|
965
1044
|
}
|
|
966
|
-
/**
|
|
967
|
-
|
|
968
|
-
|
|
1045
|
+
/**
|
|
1046
|
+
* Base interface for all context content variants.
|
|
1047
|
+
* Uses a discriminated union pattern where the `kind` field determines the concrete type.
|
|
1048
|
+
* @template Kind - A string literal type that identifies the specific content variant.
|
|
1049
|
+
*/
|
|
1050
|
+
interface BaseContextContent<Kind extends string> {
|
|
1051
|
+
kind: Kind;
|
|
1052
|
+
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Supported payload for text-based context.
|
|
1055
|
+
* Extends the base interface with a fixed `"text"` kind.
|
|
1056
|
+
*/
|
|
1057
|
+
interface TextContextContent extends BaseContextContent<"text"> {
|
|
1058
|
+
/** The raw text content. */
|
|
969
1059
|
value: string;
|
|
970
|
-
}
|
|
971
|
-
/**
|
|
972
|
-
|
|
973
|
-
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Supported payload for structured JSON context.
|
|
1063
|
+
* Extends the base interface with a fixed `"json"` kind.
|
|
1064
|
+
*/
|
|
1065
|
+
interface JsonContextContent extends BaseContextContent<"json"> {
|
|
1066
|
+
/** The parsed JSON value (can be any valid JSON type). */
|
|
974
1067
|
value: unknown;
|
|
975
|
-
}
|
|
976
|
-
/**
|
|
977
|
-
|
|
978
|
-
|
|
1068
|
+
}
|
|
1069
|
+
/**
|
|
1070
|
+
* Supported payload for blob-based context (binary data identified by hash).
|
|
1071
|
+
* Extends the base interface with a fixed `"blob"` kind.
|
|
1072
|
+
*/
|
|
1073
|
+
interface BlobContextContent extends BaseContextContent<"blob"> {
|
|
1074
|
+
/** SHA-256 hash of the blob content. */
|
|
979
1075
|
sha256: SHA256;
|
|
1076
|
+
/** MIME type of the blob. */
|
|
980
1077
|
mediaType: BlobMediaType;
|
|
1078
|
+
/** Size of the blob in bytes. */
|
|
981
1079
|
sizeBytes: number;
|
|
1080
|
+
/** Optional suggested filename. */
|
|
982
1081
|
filename?: string;
|
|
983
|
-
}
|
|
984
|
-
/**
|
|
985
|
-
|
|
986
|
-
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* Supported payload for remote URI context (content accessible via URL).
|
|
1085
|
+
* Extends the base interface with a fixed `"remote"` kind.
|
|
1086
|
+
*/
|
|
1087
|
+
interface RemoteContextContent extends BaseContextContent<"remote"> {
|
|
1088
|
+
/** The URI where the content can be retrieved. */
|
|
987
1089
|
uri: URI;
|
|
1090
|
+
/** Optional MIME type hint for the remote content. */
|
|
988
1091
|
mediaType?: BlobMediaType;
|
|
989
|
-
}
|
|
1092
|
+
}
|
|
990
1093
|
/** Union of built-in context types. */
|
|
991
1094
|
type DefaultContextContent = TextContextContent | JsonContextContent | BlobContextContent | RemoteContextContent;
|
|
992
1095
|
/**
|
|
993
1096
|
* Discriminated union of types that can be injected into the AI context.
|
|
994
1097
|
* Extensions provide their own T which MUST include a unique 'kind' discriminator.
|
|
995
1098
|
*/
|
|
996
|
-
type ContextContent<T = any> = DefaultContextContent | T;
|
|
1099
|
+
type ContextContent<T extends BaseContextContent<any> = any> = DefaultContextContent | T;
|
|
997
1100
|
/** A contextual item (file, snippet, or data) attached to a session or prompt. */
|
|
998
|
-
interface Context<T = any> {
|
|
1101
|
+
interface Context<T extends BaseContextContent<any> = any> {
|
|
999
1102
|
/** Unique lookup key for this context entry. */
|
|
1000
1103
|
key: string;
|
|
1001
1104
|
/** Topics linking this context to relevant sessions or roles. */
|
|
@@ -1019,6 +1122,10 @@ interface SessionMetadata {
|
|
|
1019
1122
|
topics: string[];
|
|
1020
1123
|
/** Array of UUIDs pointing to explicitly active preferences for this session. */
|
|
1021
1124
|
preferences: UUID[];
|
|
1125
|
+
/** Array of keys pointing to explicitly active context for this session. */
|
|
1126
|
+
context?: Array<string>;
|
|
1127
|
+
/** Array of keys pointing to explicitly active context for this session. */
|
|
1128
|
+
artifacts?: Array<string>;
|
|
1022
1129
|
/** Timestamps detailing the session lifecycle. */
|
|
1023
1130
|
metadata: {
|
|
1024
1131
|
/** UTC timestamp of session creation. */
|
|
@@ -1065,6 +1172,21 @@ interface PreferenceSummary {
|
|
|
1065
1172
|
/** A truncated preview string of the preference content. */
|
|
1066
1173
|
snippet?: string;
|
|
1067
1174
|
}
|
|
1175
|
+
/** In-memory summary of an Artifact. */
|
|
1176
|
+
interface ArtifactSummary {
|
|
1177
|
+
/** The unique key for the artifact. */
|
|
1178
|
+
key: string;
|
|
1179
|
+
/** Incrementing number representing edits. */
|
|
1180
|
+
version: number;
|
|
1181
|
+
/** Associated semantic topics. */
|
|
1182
|
+
topics: string[];
|
|
1183
|
+
/** UTC timestamp of the last update. */
|
|
1184
|
+
timestamp: Timestamp;
|
|
1185
|
+
/** Human-readable label. */
|
|
1186
|
+
label: string;
|
|
1187
|
+
/** Status (complete or draft). */
|
|
1188
|
+
status: "complete" | "draft";
|
|
1189
|
+
}
|
|
1068
1190
|
/** In-memory summary of a Context entry. */
|
|
1069
1191
|
interface ContextSummary {
|
|
1070
1192
|
/** The unique key for the context item. */
|
|
@@ -1111,6 +1233,8 @@ interface Index<T extends IndexExtensions = IndexExtensions> {
|
|
|
1111
1233
|
roles: Record<string, RoleSummary>;
|
|
1112
1234
|
/** Lookup dictionary of Preferences by their UUID. */
|
|
1113
1235
|
preferences: Record<UUID, PreferenceSummary>;
|
|
1236
|
+
/** Lookup dictionary of Artifacts by their unique key. */
|
|
1237
|
+
artifacts: Record<string, ArtifactSummary>;
|
|
1114
1238
|
/** Lookup dictionary of Context entries by their specific key. */
|
|
1115
1239
|
context: Record<string, ContextSummary>;
|
|
1116
1240
|
/** Lookup dictionary of active Sessions by their UUID. */
|
|
@@ -1261,6 +1385,27 @@ interface DeleteContext extends BaseCommand {
|
|
|
1261
1385
|
key: string;
|
|
1262
1386
|
};
|
|
1263
1387
|
}
|
|
1388
|
+
interface AddArtifact extends BaseCommand {
|
|
1389
|
+
type: "artifact:add";
|
|
1390
|
+
/** The complete artifact object to register. */
|
|
1391
|
+
payload: Artifact & {
|
|
1392
|
+
sessionId: UUID;
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
interface UpdateArtifact extends BaseCommand {
|
|
1396
|
+
type: "artifact:update";
|
|
1397
|
+
/** Delta properties to update an existing artifact record. */
|
|
1398
|
+
payload: ArtifactUpdate & {
|
|
1399
|
+
sessionId: UUID;
|
|
1400
|
+
};
|
|
1401
|
+
}
|
|
1402
|
+
interface DeleteArtifact extends BaseCommand {
|
|
1403
|
+
type: "artifact:delete";
|
|
1404
|
+
/** Key of the artifact to destroy. */
|
|
1405
|
+
payload: {
|
|
1406
|
+
key: string;
|
|
1407
|
+
};
|
|
1408
|
+
}
|
|
1264
1409
|
/** Updates an existing turn record in storage. */
|
|
1265
1410
|
interface UpdateTurn extends BaseCommand {
|
|
1266
1411
|
type: "turn:update";
|
|
@@ -1365,7 +1510,11 @@ interface UpdateSession extends BaseCommand {
|
|
|
1365
1510
|
role?: string;
|
|
1366
1511
|
topics?: string[];
|
|
1367
1512
|
preferences?: UUID[];
|
|
1513
|
+
context?: string[];
|
|
1514
|
+
artifacts?: string[];
|
|
1368
1515
|
metadata?: SessionMetadata["metadata"];
|
|
1516
|
+
head?: SessionMetadata["head"];
|
|
1517
|
+
constraints?: SessionMetadata["constraints"];
|
|
1369
1518
|
};
|
|
1370
1519
|
}
|
|
1371
1520
|
interface DeleteSession extends BaseCommand {
|
|
@@ -1471,7 +1620,7 @@ interface ToolCallCommand extends BaseCommand {
|
|
|
1471
1620
|
payload: ToolCall;
|
|
1472
1621
|
}
|
|
1473
1622
|
/** Union of all possible commands that can be dispatched to the Workspace Manager. */
|
|
1474
|
-
type Command = CreateWorkspace | SyncWorkspace | AddRole | UpdateRole | DeleteRole | AddPreference | UpdatePreference | DeletePreference | CreateSession | UpdateSession | ForkSession | DeleteSession | SwitchSessionRole | AddSessionTopics | OverrideSessionPreferences | AddContext | UpdateContext | DeleteContext | UpdateTurn | AddTurn | EditTurn | BranchTurn | DeleteTurn | RegisterBlob | RetainBlob | ReleaseBlob | PurgeBlob | RecordBlobRemoteId | AddTopic | UpdateTopic | DeleteTopic | MergeTopics | ToolCallCommand;
|
|
1623
|
+
type Command = CreateWorkspace | SyncWorkspace | AddRole | UpdateRole | DeleteRole | AddPreference | UpdatePreference | DeletePreference | CreateSession | UpdateSession | ForkSession | DeleteSession | SwitchSessionRole | AddSessionTopics | OverrideSessionPreferences | AddContext | UpdateContext | DeleteContext | AddArtifact | UpdateArtifact | DeleteArtifact | UpdateTurn | AddTurn | EditTurn | BranchTurn | DeleteTurn | RegisterBlob | RetainBlob | ReleaseBlob | PurgeBlob | RecordBlobRemoteId | AddTopic | UpdateTopic | DeleteTopic | MergeTopics | ToolCallCommand;
|
|
1475
1624
|
/**
|
|
1476
1625
|
* Standard reducer pattern for updating workspace state.
|
|
1477
1626
|
* @template T - Custom contextual additions for the reducer parameters.
|
|
@@ -1541,6 +1690,8 @@ interface SessionSnapshot {
|
|
|
1541
1690
|
preferences: Preference[];
|
|
1542
1691
|
/** All context entries whose topics overlap with the session's active topics. */
|
|
1543
1692
|
context: Context[];
|
|
1693
|
+
/** Array of keys pointing to explicitly active context for this session. */
|
|
1694
|
+
artifacts: Array<Artifact>;
|
|
1544
1695
|
/** Full active chain from TurnTree — oldest to newest. Untruncated. */
|
|
1545
1696
|
transcript: Turn[];
|
|
1546
1697
|
/** The session's active semantic topic set. */
|
|
@@ -1695,50 +1846,20 @@ interface AssemblerExtension extends PromptSection {
|
|
|
1695
1846
|
}
|
|
1696
1847
|
/**
|
|
1697
1848
|
* Provider-agnostic system prompt assembler.
|
|
1698
|
-
*
|
|
1699
|
-
* Builds an ordered array of labelled sections from a Prompt plus any
|
|
1700
|
-
* adapter-injected extensions. The adapter calls join() to produce the
|
|
1701
|
-
* final string it wraps in its provider envelope.
|
|
1702
|
-
*
|
|
1703
|
-
* Responsibilities:
|
|
1704
|
-
* - Render core sections from Prompt fields in canonical order.
|
|
1705
|
-
* - Slot extensions at their declared anchor positions.
|
|
1706
|
-
* - Produce a consistent, inspectable section array.
|
|
1707
|
-
* - Join sections into a single string on demand.
|
|
1708
|
-
*
|
|
1709
|
-
* Not responsible for:
|
|
1710
|
-
* - Provider-specific wrapping (Content, system message, etc.).
|
|
1711
|
-
* - Block architecture text — the adapter injects that as an extension.
|
|
1712
|
-
* - Truncation — that is the adapter's concern.
|
|
1713
1849
|
*/
|
|
1714
1850
|
interface SystemPromptAssembler {
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
* they appear in the extensions array.
|
|
1728
|
-
*
|
|
1729
|
-
* Core sections with no content (e.g. empty preferences, absent instructions)
|
|
1730
|
-
* are omitted from the output entirely.
|
|
1731
|
-
*
|
|
1732
|
-
* @param prompt - The fully built Prompt from PromptBuilder.
|
|
1733
|
-
* @param extensions - Additional sections injected by the adapter or app layer.
|
|
1734
|
-
*/
|
|
1735
|
-
build(prompt: Prompt, extensions?: AssemblerExtension[]): PromptSection[];
|
|
1736
|
-
/**
|
|
1737
|
-
* Joins an array of PromptSections into a single string suitable for
|
|
1738
|
-
* passing to the model. Uses a consistent separator that works across providers.
|
|
1739
|
-
*
|
|
1740
|
-
* @param sections - The output of build().
|
|
1741
|
-
*/
|
|
1851
|
+
build<P, C>(provider: string, prompt: Prompt, mapTurn: (args: {
|
|
1852
|
+
turn: Turn;
|
|
1853
|
+
parts: P[];
|
|
1854
|
+
}) => C, extensions?: AssemblerExtension[]): Promise<{
|
|
1855
|
+
system: string;
|
|
1856
|
+
transcript: C[];
|
|
1857
|
+
sections: PromptSection[];
|
|
1858
|
+
}>;
|
|
1859
|
+
parse(provider: string, raw: Array<{
|
|
1860
|
+
type: string;
|
|
1861
|
+
[key: string]: any;
|
|
1862
|
+
}>): BaseContentBlock<any>[];
|
|
1742
1863
|
join(sections: PromptSection[]): string;
|
|
1743
1864
|
}
|
|
1744
1865
|
type BlockMapper = {
|
|
@@ -1746,7 +1867,7 @@ type BlockMapper = {
|
|
|
1746
1867
|
* Convert a workspace block into a provider-specific part.
|
|
1747
1868
|
* The return type is `unknown` — the adapter casts it internally.
|
|
1748
1869
|
*/
|
|
1749
|
-
to(block: BaseContentBlock<string>): unknown
|
|
1870
|
+
to(block: BaseContentBlock<string>): unknown | Promise<unknown>;
|
|
1750
1871
|
/**
|
|
1751
1872
|
* Convert a provider-extracted raw JSON object into a workspace block.
|
|
1752
1873
|
* Return `null` if parsing fails.
|
|
@@ -1836,7 +1957,7 @@ interface WorkspaceServices {
|
|
|
1836
1957
|
* Output of PromptBuilder.build(). Input to LLMAdapter.resolve().
|
|
1837
1958
|
*
|
|
1838
1959
|
* Contains fully ranked and conflict-resolved preferences, context, and a
|
|
1839
|
-
* catalogue of blob references
|
|
1960
|
+
* catalogue of blob references - but is NOT truncated and does NOT contain
|
|
1840
1961
|
* resolved binary blob data. The adapter is responsible for:
|
|
1841
1962
|
* - Deciding what fits within the model's context window.
|
|
1842
1963
|
* - Resolving only the BlobRefs that survive truncation.
|
|
@@ -1858,6 +1979,8 @@ interface Prompt {
|
|
|
1858
1979
|
/** Ranked context entries (text and json kinds only). Blob context is
|
|
1859
1980
|
* represented as referential blocks in the transcript instead. */
|
|
1860
1981
|
context: Context[];
|
|
1982
|
+
/** Ranked artifact entries included after adapter-level truncation. */
|
|
1983
|
+
artifacts: Artifact[];
|
|
1861
1984
|
/** Additional sections injected by the adapter or application layer. */
|
|
1862
1985
|
extensions?: AssemblerExtension[];
|
|
1863
1986
|
};
|
|
@@ -1868,12 +1991,12 @@ interface Prompt {
|
|
|
1868
1991
|
* Lightweight catalogue of every blob referenced anywhere in this prompt
|
|
1869
1992
|
* (system.context or transcript), keyed by SHA256.
|
|
1870
1993
|
*
|
|
1871
|
-
* Values are BlobRefs
|
|
1994
|
+
* Values are BlobRefs - metadata only, no binary data. The adapter uses
|
|
1872
1995
|
* this catalogue to resolve or upload blobs for whichever turns and context
|
|
1873
1996
|
* entries survive its truncation pass.
|
|
1874
1997
|
*/
|
|
1875
1998
|
blobs: Map<SHA256, BlobRef>;
|
|
1876
|
-
/** The role object
|
|
1999
|
+
/** The role object - for inspection and adapter use. */
|
|
1877
2000
|
role: Role;
|
|
1878
2001
|
/** Model constraints to be merged by the adapter (turn > session > role). */
|
|
1879
2002
|
constraints: ModelConstraintMap;
|
|
@@ -1900,7 +2023,7 @@ interface AdapterStatus {
|
|
|
1900
2023
|
size: number;
|
|
1901
2024
|
/** Maximum output tokens for this model. */
|
|
1902
2025
|
out: number;
|
|
1903
|
-
/** Tokens remaining
|
|
2026
|
+
/** Tokens remaining - estimated or as reported by the provider. */
|
|
1904
2027
|
free?: number;
|
|
1905
2028
|
};
|
|
1906
2029
|
/** Capability flags for this model. */
|
|
@@ -1954,7 +2077,7 @@ interface AdapterStatus {
|
|
|
1954
2077
|
/**
|
|
1955
2078
|
* The result of `PreparedPrompt.execute()`. Contains the turn and derived effects.
|
|
1956
2079
|
*/
|
|
1957
|
-
interface
|
|
2080
|
+
interface PromptResult {
|
|
1958
2081
|
/** The newly generated assistant turn. */
|
|
1959
2082
|
turn: Turn;
|
|
1960
2083
|
/** Side-effect commands to dispatch against the workspace. */
|
|
@@ -1962,7 +2085,7 @@ interface ExecuteResult {
|
|
|
1962
2085
|
}
|
|
1963
2086
|
/**
|
|
1964
2087
|
* A single labelled section of the system prompt.
|
|
1965
|
-
* Mirrors PreparedPrompt.system exactly
|
|
2088
|
+
* Mirrors PreparedPrompt.system exactly - the assembler's output is stored
|
|
1966
2089
|
* there directly, giving callers full inspection without re-parsing the string.
|
|
1967
2090
|
*/
|
|
1968
2091
|
interface PromptSection {
|
|
@@ -1993,6 +2116,8 @@ interface PreparedPrompt {
|
|
|
1993
2116
|
transcript: Turn[];
|
|
1994
2117
|
/** Final context entries included after adapter-level truncation. */
|
|
1995
2118
|
context: Context[];
|
|
2119
|
+
/** Final artifact entries included after adapter-level truncation. */
|
|
2120
|
+
artifacts: Artifact[];
|
|
1996
2121
|
/** Final preferences included after adapter-level truncation. */
|
|
1997
2122
|
preferences: Preference[];
|
|
1998
2123
|
/** The resolved model constraints for this request. */
|
|
@@ -2001,7 +2126,7 @@ interface PreparedPrompt {
|
|
|
2001
2126
|
tokens: {
|
|
2002
2127
|
/** Breakdown by section. Keys are adapter-defined. */
|
|
2003
2128
|
breakdown: Record<string, number>;
|
|
2004
|
-
/** Total input tokens
|
|
2129
|
+
/** Total input tokens - estimated or exact. */
|
|
2005
2130
|
total: number;
|
|
2006
2131
|
/** Whether total is an estimate or exact (provider-supplied). */
|
|
2007
2132
|
source: "estimated" | "exact";
|
|
@@ -2014,12 +2139,12 @@ interface PreparedPrompt {
|
|
|
2014
2139
|
* Sends this prompt to the model.
|
|
2015
2140
|
* @returns The parsed assistant Turn plus any execution side-effects.
|
|
2016
2141
|
*/
|
|
2017
|
-
execute(): Promise<Result<
|
|
2142
|
+
execute(): Promise<Result<PromptResult, WorkspaceError>>;
|
|
2018
2143
|
/**
|
|
2019
2144
|
* Streaming variant of execute(). Yields partial turns as tokens arrive.
|
|
2020
2145
|
* Present only if the adapter and model support streaming.
|
|
2021
2146
|
*/
|
|
2022
|
-
executeStream?(): AsyncIterable<Partial<Turn> |
|
|
2147
|
+
executeStream?(): AsyncIterable<Partial<Turn> | PromptResult>;
|
|
2023
2148
|
}
|
|
2024
2149
|
|
|
2025
2150
|
/**
|
|
@@ -2177,6 +2302,7 @@ declare const COLLECTIONS: {
|
|
|
2177
2302
|
readonly TURN: "turn";
|
|
2178
2303
|
readonly BLOB: "blob";
|
|
2179
2304
|
readonly TOPIC: "topic";
|
|
2305
|
+
readonly ARTIFACT: "artifact";
|
|
2180
2306
|
};
|
|
2181
2307
|
type Collections = (typeof COLLECTIONS)[keyof typeof COLLECTIONS];
|
|
2182
2308
|
|
|
@@ -2202,6 +2328,22 @@ declare class ContextStore implements Store<Context, ContextSummary, string> {
|
|
|
2202
2328
|
summarize(context: Context): ContextSummary;
|
|
2203
2329
|
}
|
|
2204
2330
|
|
|
2331
|
+
declare class ArtifactStore implements Store<Artifact, ArtifactSummary, string> {
|
|
2332
|
+
private readonly collection;
|
|
2333
|
+
private readonly cache;
|
|
2334
|
+
constructor(collection: Collection<Artifact>, cache: LRUCache<string, Artifact>);
|
|
2335
|
+
get(key: string): Promise<Artifact | null>;
|
|
2336
|
+
add(artifact: Artifact): Promise<void>;
|
|
2337
|
+
update(key: string, updates: Partial<Artifact>): Promise<Artifact | null>;
|
|
2338
|
+
delete(key: string): Promise<boolean>;
|
|
2339
|
+
list(): Promise<Artifact[]>;
|
|
2340
|
+
/**
|
|
2341
|
+
* Retrieves all artifacts referenced by the given topics using the in-memory index.
|
|
2342
|
+
*/
|
|
2343
|
+
getByTopics(index: Index, topics: string[]): Promise<Artifact[]>;
|
|
2344
|
+
summarize(artifact: Artifact): ArtifactSummary;
|
|
2345
|
+
}
|
|
2346
|
+
|
|
2205
2347
|
declare class PreferenceStore implements Store<Preference, PreferenceSummary, UUID> {
|
|
2206
2348
|
private readonly collection;
|
|
2207
2349
|
private readonly cache;
|
|
@@ -2322,7 +2464,7 @@ type Indexer = (ctx: WorkspaceContext) => Promise<DeepPartial<Workspace>>;
|
|
|
2322
2464
|
/**
|
|
2323
2465
|
* Definition of a specific kind of context and how the system interacts with it.
|
|
2324
2466
|
*/
|
|
2325
|
-
interface ContextDefinition<T = any> {
|
|
2467
|
+
interface ContextDefinition<T extends BaseContextContent<any> = any> {
|
|
2326
2468
|
/** Unique discriminator for this context kind (e.g., 'text', 'blob', 'task'). */
|
|
2327
2469
|
kind: string;
|
|
2328
2470
|
/**
|
|
@@ -2384,6 +2526,8 @@ type WorkspaceContext<ProjectMetadata extends Record<string, any> = Record<strin
|
|
|
2384
2526
|
preferences: PreferenceStore;
|
|
2385
2527
|
/** Store for managing RAG-retrievable context entries. */
|
|
2386
2528
|
context: ContextStore;
|
|
2529
|
+
/** Store for managing durable conversational artifacts. */
|
|
2530
|
+
artifacts: ArtifactStore;
|
|
2387
2531
|
/** Store for managing active and archived conversation sessions. */
|
|
2388
2532
|
sessions: SessionStore;
|
|
2389
2533
|
/** Store for managing topic metadata and indexing. */
|
|
@@ -2770,6 +2914,26 @@ declare class Session {
|
|
|
2770
2914
|
* @param preferenceIds - Array of preference UUIDs.
|
|
2771
2915
|
*/
|
|
2772
2916
|
setPreferences(preferenceIds: UUID[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2917
|
+
/**
|
|
2918
|
+
* Replaces the session’s context list.
|
|
2919
|
+
* @param contextKeys - New array of context keys.
|
|
2920
|
+
*/
|
|
2921
|
+
setContext(contextKeys: string[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2922
|
+
/**
|
|
2923
|
+
* Adds context keys to the session (does not replace existing ones).
|
|
2924
|
+
* @param contextKeys - Context keys to add.
|
|
2925
|
+
*/
|
|
2926
|
+
addContext(contextKeys: string[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2927
|
+
/**
|
|
2928
|
+
* Removes context keys from the session.
|
|
2929
|
+
* @param contextKeys - Context keys to remove.
|
|
2930
|
+
*/
|
|
2931
|
+
removeContext(contextKeys: string[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2932
|
+
/**
|
|
2933
|
+
* Replaces the session’s artifact list.
|
|
2934
|
+
* @param artifactKeys - New array of artifact keys.
|
|
2935
|
+
*/
|
|
2936
|
+
setArtifacts(artifactKeys: string[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2773
2937
|
/**
|
|
2774
2938
|
* Creates a new session as a fork of this one.
|
|
2775
2939
|
* @param newSessionId - ID for the new session.
|
|
@@ -2882,6 +3046,7 @@ declare class SessionManager {
|
|
|
2882
3046
|
role: string;
|
|
2883
3047
|
topics: string[];
|
|
2884
3048
|
preferences?: UUID[];
|
|
3049
|
+
metadata?: Record<string, any>;
|
|
2885
3050
|
}): Promise<Session>;
|
|
2886
3051
|
list(): SessionMetadata[];
|
|
2887
3052
|
metadata(sessionId: UUID): SessionMetadata | undefined;
|
|
@@ -2903,7 +3068,7 @@ declare class TurnBuilder {
|
|
|
2903
3068
|
addSummary(text: string): TurnBuilder;
|
|
2904
3069
|
addRoleTransition(previousRole: string | undefined, newRole: string): TurnBuilder;
|
|
2905
3070
|
addThinking(thinking: string): TurnBuilder;
|
|
2906
|
-
addBlock(block:
|
|
3071
|
+
addBlock(block: BaseContentBlock<any>): TurnBuilder;
|
|
2907
3072
|
deleteBlock(blockId: UUID): TurnBuilder;
|
|
2908
3073
|
editTextBlock(blockId: UUID, newText: string): TurnBuilder;
|
|
2909
3074
|
withId(id: UUID): TurnBuilder;
|
|
@@ -2931,25 +3096,39 @@ declare class DefaultPromptBuilder implements PromptBuilder {
|
|
|
2931
3096
|
build(snapshot: SessionSnapshot, _: WorkspaceContext, options?: PromptBuilderOptions): Promise<Result<Prompt, WorkspaceError>>;
|
|
2932
3097
|
}
|
|
2933
3098
|
|
|
2934
|
-
declare class
|
|
3099
|
+
declare class PromptAssembler implements SystemPromptAssembler {
|
|
3100
|
+
private readonly registry;
|
|
3101
|
+
constructor(registry: ContentBlockRegistry);
|
|
3102
|
+
build<P, C>(provider: string, prompt: Prompt, mapTurn: (args: {
|
|
3103
|
+
turn: Turn;
|
|
3104
|
+
parts: P[];
|
|
3105
|
+
}) => C, extensions?: AssemblerExtension[]): Promise<{
|
|
3106
|
+
system: string;
|
|
3107
|
+
sections: PromptSection[];
|
|
3108
|
+
transcript: C[];
|
|
3109
|
+
}>;
|
|
3110
|
+
private buildSections;
|
|
2935
3111
|
/**
|
|
2936
|
-
*
|
|
3112
|
+
* Parses an array of raw block objects from a model response into typed
|
|
3113
|
+
* workspace ContentBlocks via the registry.
|
|
3114
|
+
*
|
|
3115
|
+
* The caller (adapter + response.ts) owns wire-format extraction — pulling
|
|
3116
|
+
* the raw blocks array out of the provider envelope. This method owns only
|
|
3117
|
+
* the registry dispatch: raw → registry.parse(raw, providerId) → ContentBlock.
|
|
2937
3118
|
*
|
|
2938
|
-
*
|
|
2939
|
-
*
|
|
2940
|
-
* 2. Drop any core section that has no meaningful content.
|
|
2941
|
-
* 3. Walk the extensions array and splice each one into the result at
|
|
2942
|
-
* its declared anchor position.
|
|
2943
|
-
* 4. Return the final ordered array.
|
|
3119
|
+
* Unknown or unregistered block types are skipped (registry returns null
|
|
3120
|
+
* and logs a warning). This method never throws on bad input.
|
|
2944
3121
|
*/
|
|
2945
|
-
|
|
3122
|
+
parse(provider: string, rawBlocks: Array<{
|
|
3123
|
+
type: string;
|
|
3124
|
+
[key: string]: any;
|
|
3125
|
+
}>): ContentBlock[];
|
|
2946
3126
|
/**
|
|
2947
3127
|
* Joins an ordered array of PromptSections into a single string.
|
|
2948
|
-
* Uses a consistent separator that renders clearly across providers.
|
|
2949
3128
|
*/
|
|
2950
3129
|
join(sections: PromptSection[]): string;
|
|
2951
3130
|
}
|
|
2952
|
-
declare function createDefaultAssembler():
|
|
3131
|
+
declare function createDefaultAssembler(registry: ContentBlockRegistry): PromptAssembler;
|
|
2953
3132
|
|
|
2954
3133
|
declare class JaccardContextRetriever implements ContextRetriever {
|
|
2955
3134
|
private readonly contextRegistry;
|
|
@@ -3096,7 +3275,7 @@ declare class GoogleGenAIAdapter implements LLMAdapter<GenerateContentParameters
|
|
|
3096
3275
|
model: string;
|
|
3097
3276
|
models?: Array<ModelProfile>;
|
|
3098
3277
|
});
|
|
3099
|
-
private
|
|
3278
|
+
private registerMappings;
|
|
3100
3279
|
status(_?: string): Promise<AdapterStatus>;
|
|
3101
3280
|
resolve(params: {
|
|
3102
3281
|
prompt: Prompt;
|
|
@@ -3109,47 +3288,56 @@ declare const mappings: Record<string, BlockMapper>;
|
|
|
3109
3288
|
|
|
3110
3289
|
declare const GOOGLE_MODELS: Array<ModelProfile>;
|
|
3111
3290
|
|
|
3291
|
+
type RawBlock = {
|
|
3292
|
+
type: string;
|
|
3293
|
+
[key: string]: any;
|
|
3294
|
+
};
|
|
3112
3295
|
/**
|
|
3113
|
-
*
|
|
3296
|
+
* What the wire-format extraction layer returns to the adapter.
|
|
3114
3297
|
*
|
|
3115
|
-
*
|
|
3116
|
-
*
|
|
3117
|
-
*
|
|
3118
|
-
*
|
|
3119
|
-
*
|
|
3120
|
-
*
|
|
3121
|
-
*
|
|
3122
|
-
*/
|
|
3123
|
-
|
|
3124
|
-
|
|
3298
|
+
* - `thinking` — zero or more thinking blocks, fully constructed (they carry
|
|
3299
|
+
* no registry mapping; their shape is fixed by the protocol).
|
|
3300
|
+
* - `rawBlocks` — the JSON blocks array from the model's structured output,
|
|
3301
|
+
* unparsed. The adapter hands these to assembler.parse().
|
|
3302
|
+
* - `fallback` — set instead of rawBlocks when the model returned raw text
|
|
3303
|
+
* rather than the requested JSON schema. The adapter wraps
|
|
3304
|
+
* this in a TextBlock via wrapAsTextBlock.
|
|
3305
|
+
*/
|
|
3306
|
+
type ExtractionResult = {
|
|
3307
|
+
ok: true;
|
|
3308
|
+
thinking: ThinkingBlock[];
|
|
3309
|
+
rawBlocks: RawBlock[];
|
|
3310
|
+
} | {
|
|
3311
|
+
ok: true;
|
|
3312
|
+
thinking: ThinkingBlock[];
|
|
3313
|
+
fallback: string;
|
|
3314
|
+
} | {
|
|
3315
|
+
ok: false;
|
|
3316
|
+
thinking: ThinkingBlock[];
|
|
3317
|
+
error: WorkspaceError;
|
|
3318
|
+
};
|
|
3125
3319
|
/**
|
|
3126
|
-
*
|
|
3320
|
+
* Extracts structured data from a Gemini GenerateContentResponse.
|
|
3127
3321
|
*
|
|
3128
|
-
*
|
|
3129
|
-
*
|
|
3130
|
-
*
|
|
3131
|
-
*
|
|
3132
|
-
|
|
3133
|
-
declare function mapTurnToContent(turn: Turn, resolveBlob: BlobResolver, registry: ContentBlockRegistry): Promise<Content>;
|
|
3134
|
-
/**
|
|
3135
|
-
* Maps a single workspace block to a Gemini Part via the registry's provider mapping.
|
|
3322
|
+
* Responsibility:
|
|
3323
|
+
* - Owns the Gemini wire format: candidates, parts, thought flag.
|
|
3324
|
+
* - Separates thinking parts from the JSON payload.
|
|
3325
|
+
* - Returns raw blocks (unparsed) or a fallback string.
|
|
3326
|
+
* - Has no knowledge of the block registry or provider mappings.
|
|
3136
3327
|
*
|
|
3137
|
-
*
|
|
3138
|
-
* appear in a transcript must have a Gemini mapping registered by the adapter at
|
|
3139
|
-
* initialisation time. There is no silent fallback: an unmapped block is a gap in
|
|
3140
|
-
* the adapter's setup, not a recoverable runtime condition.
|
|
3328
|
+
* Registry dispatch (raw → ContentBlock) is the assembler's job.
|
|
3141
3329
|
*/
|
|
3142
|
-
declare function
|
|
3330
|
+
declare function extractModelResponse(response: GenerateContentResponse): ExtractionResult;
|
|
3143
3331
|
|
|
3332
|
+
type index_ExtractionResult = ExtractionResult;
|
|
3144
3333
|
declare const index_GOOGLE_MODELS: typeof GOOGLE_MODELS;
|
|
3145
3334
|
type index_GoogleGenAIAdapter = GoogleGenAIAdapter;
|
|
3146
3335
|
declare const index_GoogleGenAIAdapter: typeof GoogleGenAIAdapter;
|
|
3147
|
-
|
|
3148
|
-
declare const
|
|
3336
|
+
type index_RawBlock = RawBlock;
|
|
3337
|
+
declare const index_extractModelResponse: typeof extractModelResponse;
|
|
3149
3338
|
declare const index_mappings: typeof mappings;
|
|
3150
|
-
declare const index_parseModelResponse: typeof parseModelResponse;
|
|
3151
3339
|
declare namespace index {
|
|
3152
|
-
export { index_GOOGLE_MODELS as GOOGLE_MODELS, index_GoogleGenAIAdapter as GoogleGenAIAdapter,
|
|
3340
|
+
export { type index_ExtractionResult as ExtractionResult, index_GOOGLE_MODELS as GOOGLE_MODELS, index_GoogleGenAIAdapter as GoogleGenAIAdapter, type index_RawBlock as RawBlock, index_extractModelResponse as extractModelResponse, index_mappings as mappings };
|
|
3153
3341
|
}
|
|
3154
3342
|
|
|
3155
3343
|
interface CreateWorkspaceParams {
|
|
@@ -3211,4 +3399,4 @@ declare function createWorkspace(params: CreateWorkspaceParams): Promise<{
|
|
|
3211
3399
|
bootstrap: (config: BootstrapConfig) => Promise<BootstrapResult>;
|
|
3212
3400
|
}>;
|
|
3213
3401
|
|
|
3214
|
-
export { type AdapterStatus, type AddContext, type AddPreference, type AddRole, type AddSessionTopics, type AddTopic, type AddTurn, type AssemblerExtension, type AuthRequest, type BackendError, type BaseCommand, type BaseContentBlock, type BlobCommand, type BlobContextContent, type BlobError, type BlobMediaType, type BlobRecord, type BlobRef, type BlobResolver, type BlockMapper, type BootstrapConfig, type BootstrapResult, type BranchInfo, type BranchTurn, COLLECTIONS, type CheckpointBlock, type CheckpointSessionState, type Collections, type Command, type ContentBlock, type ContentBlockDefinition, type Context, type ContextContent, type ContextDefinition, type ContextRetriever, type ContextSummary, type CreateSession, type CreateWorkspace, type CreateWorkspaceParams, type DeepPartial, type DefaultContextContent, DefaultPromptBuilder,
|
|
3402
|
+
export { type AdapterStatus, type AddArtifact, type AddContext, type AddPreference, type AddRole, type AddSessionTopics, type AddTopic, type AddTurn, type Artifact, type ArtifactSummary, type AssemblerExtension, type AuthRequest, type BackendError, type BaseCommand, type BaseContentBlock, type BaseContextContent, type BlobCommand, type BlobContextContent, type BlobError, type BlobMediaType, type BlobRecord, type BlobRef, type BlobResolver, type BlockMapper, type BootstrapConfig, type BootstrapResult, type BranchInfo, type BranchTurn, COLLECTIONS, type CheckpointBlock, type CheckpointSessionState, type Collections, type Command, type ContentBlock, type ContentBlockDefinition, type Context, type ContextContent, type ContextDefinition, type ContextRetriever, type ContextSummary, type CreateSession, type CreateWorkspace, type CreateWorkspaceParams, type DeepPartial, type DefaultContextContent, DefaultPromptBuilder, type DeleteArtifact, type DeleteContext, type DeletePreference, type DeleteRole, type DeleteSession, type DeleteTopic, type DeleteTurn, type DocumentBlock, type DocumentMediaType, type DuplicateKeyError, EMPTY_SYSTEM_ROLE, type EditTurn, type ForkSession, index as GoogleAdapter, type ImageBlock, type ImageMediaType, type Index, type IndexExtensions, type IndexedDBBlobConfig, IndexedDBBlobStorage, type Indexer, type InvalidCommandError, JaccardContextRetriever, type JsonContextContent, type LLMAdapter, type LLMAdapterStatic, LRUCache, MemoryBlobStorage, type MergeTopics, type ModelConstraint, type ModelConstraintMap, type ModelName, type ModelProfile, type ModelRegistry, type NotFoundError, type OverrideSessionPreferences, type PermissionDeniedError, type PermissionGuard, type Preference, type PreferenceSummary, type PreparedPrompt, type Project, type Prompt, PromptAssembler, type PromptBuilder, type PromptBuilderOptions, type PromptResult, type PromptSection, type PurgeBlob, type RecordBlobRemoteId, type RegisterBlob, type ReleaseBlob, type RemoteContextContent, type ResolvedBlob, type ResolvedSession, type Result, type RetainBlob, type Role, type RoleSummary, type RoleTransitionBlock, type SHA256, Session, SessionManager, type SessionMetadata, type SessionSnapshot, type Settings, type Store, type Summarizer, type SummaryBlock, type SwitchSessionRole, type SyncWorkspace, type SystemActor, type SystemPromptAssembler, type TextBlock, type TextContextContent, type ThinkingBlock, type Timestamp, type ToolCall, type ToolCallCommand, type ToolRegistry, type ToolResultBlock, type ToolSummary, type ToolUseBlock, type Topic, type TopicIndex, type Turn, TurnBuilder, type TurnKey, type TurnNode, type TurnProcessor, type TurnRef, TurnTree, type URI, type UUID, type UpdateArtifact, type UpdateContext, type UpdatePreference, type UpdateRole, type UpdateSession, type UpdateTopic, type UpdateTurn, type Workspace, WorkspaceApi, type WorkspaceBundle, type WorkspaceContext, type WorkspaceDatabase, type WorkspaceError, type WorkspaceEvents, type WorkspaceExtension, WorkspaceManager, type WorkspaceMiddleware, type WorkspaceReducer, WorkspaceRegistry, type WorkspaceServices, bufferToBase64, computeSHA256, createDefaultAssembler, createEmptySession, createEmptyTurn, createEmptyWorkspace, createWorkspace, createWorkspaceDatabase, del, error, getExtension, merge, omitNullUndefined, sessionStateToMarkdown, shortHash, success };
|