@prismer/runtime 2.0.0 → 2.0.1

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/index.d.cts CHANGED
@@ -865,6 +865,38 @@ declare class AssetCache {
865
865
  signal?: AbortSignal;
866
866
  assetId?: string;
867
867
  }): Promise<CachedAsset>;
868
+ /**
869
+ * Fetch a public http(s) URL, content-hash dedup, cache locally.
870
+ *
871
+ * Mirrors `getOrFetch` (cache key = sha256 of body bytes), but the input
872
+ * is a URL whose hash we don't know up front. The fetcher applies:
873
+ *
874
+ * - SSRF guard (resolve hostname, reject loopback / RFC1918 / link-local
875
+ * / cloud-metadata / IPv6 ULA + link-local). Cross-host redirects
876
+ * re-validate the new host before each hop.
877
+ * - manual redirect handling (max 3 hops).
878
+ * - hard timeout (default 15 s, override via env
879
+ * `PRISMER_URL_FETCH_TIMEOUT_MS`).
880
+ * - streaming body read with abort-at-limit (default 5 MiB, override
881
+ * via env `PRISMER_URL_FETCH_MAX_BYTES`). Truncated bodies are NOT
882
+ * cached.
883
+ * - non-2xx → throws (caller should leave the URL in place and emit
884
+ * an `error` observation).
885
+ *
886
+ * On success returns { cached, finalUrl, durationMs }; the caller can
887
+ * pin / unpin the hash like any other asset.
888
+ */
889
+ getOrFetchUrl(url: string, opts?: {
890
+ signal?: AbortSignal;
891
+ userAgent?: string;
892
+ maxBytes?: number;
893
+ timeoutMs?: number;
894
+ maxRedirects?: number;
895
+ }): Promise<{
896
+ cached: CachedAsset;
897
+ finalUrl: string;
898
+ durationMs: number;
899
+ }>;
868
900
  /** Insert an already-on-disk asset into the cache (e.g., asset just produced by adapter). */
869
901
  registerLocal(hash: string, localPath: string, mime?: string): CachedAsset;
870
902
  /** Total bytes across all rows (incl. pinned). */
@@ -1022,68 +1054,6 @@ declare class ParseClaimController {
1022
1054
  }): HeartbeatHandle;
1023
1055
  }
1024
1056
 
1025
- type PrismerUriType = 'asset' | 'file';
1026
- interface ParsedPrismerUri {
1027
- /** Original full URI string. */
1028
- raw: string;
1029
- /**
1030
- * Owner segment for legacy `prismer://<owner>/...` form (informational,
1031
- * not ACL-checked). For `prismer://workspace/<wid>/...` this is the
1032
- * literal string 'workspace' — prefer `workspaceId` instead.
1033
- */
1034
- owner: string;
1035
- type: PrismerUriType;
1036
- /** For type='asset': the sha256 hash. For legacy file URIs: '<wsId>/<path>'. */
1037
- rest: string;
1038
- /** Convenience parses for type='file' and for workspace-form 'asset'. */
1039
- workspaceId?: string;
1040
- filePath?: string;
1041
- }
1042
- /**
1043
- * Find every recognized `prismer://...` reference in a string.
1044
- * Only `asset` and `file` types are recognized — other types (memory,
1045
- * context, conversation, evolution, task, pair) pass through untouched.
1046
- */
1047
- declare function parseUris(text: string): ParsedPrismerUri[];
1048
- interface UriResolverOptions {
1049
- db: LocalDb;
1050
- cloud: CloudClient;
1051
- assetCache: AssetCache;
1052
- }
1053
- declare class UriResolver {
1054
- private readonly db;
1055
- private readonly cloud;
1056
- private readonly assetCache;
1057
- constructor(opts: UriResolverOptions);
1058
- /**
1059
- * Resolve a single URI to a local file path. Throws on auth/4xx;
1060
- * caller decides whether to leave the URI in place (best-effort) or fail.
1061
- */
1062
- resolveOne(uri: ParsedPrismerUri, opts?: {
1063
- signal?: AbortSignal;
1064
- }): Promise<string>;
1065
- /**
1066
- * Walk a string, replace every `prismer://(asset|file)/...` with `file://<localPath>`.
1067
- * Unrecognized URIs pass through. Returns rewritten text + the list of pinned hashes.
1068
- */
1069
- rewrite(text: string, opts?: {
1070
- pin?: boolean;
1071
- signal?: AbortSignal;
1072
- }): Promise<{
1073
- text: string;
1074
- resolvedHashes: string[];
1075
- }>;
1076
- /** Bulk-rewrite an array of strings (e.g. context entries' content). */
1077
- rewriteAll(texts: string[], opts?: {
1078
- pin?: boolean;
1079
- signal?: AbortSignal;
1080
- }): Promise<{
1081
- texts: string[];
1082
- resolvedHashes: string[];
1083
- }>;
1084
- private lookupFile;
1085
- }
1086
-
1087
1057
  type IMAgentStatus = 'online' | 'busy' | 'idle' | 'offline';
1088
1058
  interface HostedAgentDeclaration {
1089
1059
  imUserId: string;
@@ -1185,15 +1155,22 @@ interface TaskDispatchProgressPayload {
1185
1155
  detail?: Record<string, unknown>;
1186
1156
  }
1187
1157
  /** Wave-8 W1: how the daemon handled a single AssetRef. */
1188
- type AssetDispatchStrategy = 'inline-text' | 'inline-text-truncated' | 'uri-only' | 'error';
1158
+ type AssetDispatchStrategy = 'inline-text' | 'inline-text-truncated' | 'uri-only' | 'fetched-https' | 'error';
1189
1159
  interface AssetDispatchObservation {
1190
- assetId: string;
1160
+ /** AssetRef.assetId for cloud-attached refs; undefined for L5 https fetches. */
1161
+ assetId?: string;
1191
1162
  contentHash: string;
1192
1163
  mime: string | null;
1193
1164
  sizeBytes: number | null;
1194
1165
  strategy: AssetDispatchStrategy;
1195
1166
  inlinedBytes?: number;
1196
1167
  error?: string;
1168
+ /** L5: original URL the user wrote in the prompt. */
1169
+ originalUrl?: string;
1170
+ /** L5: post-redirect URL the body was actually downloaded from. */
1171
+ finalUrl?: string;
1172
+ /** L5: end-to-end fetch duration in ms (DNS + connect + body read). */
1173
+ durationMs?: number;
1197
1174
  }
1198
1175
  interface TaskDispatchReplyPayload {
1199
1176
  taskId: string;
@@ -1254,6 +1231,106 @@ interface AssetChangedPayload {
1254
1231
  revision?: number;
1255
1232
  }
1256
1233
 
1234
+ type PrismerUriType = 'asset' | 'file';
1235
+ interface ParsedPrismerUri {
1236
+ /** Original full URI string. */
1237
+ raw: string;
1238
+ /**
1239
+ * Owner segment for legacy `prismer://<owner>/...` form (informational,
1240
+ * not ACL-checked). For `prismer://workspace/<wid>/...` this is the
1241
+ * literal string 'workspace' — prefer `workspaceId` instead.
1242
+ */
1243
+ owner: string;
1244
+ type: PrismerUriType;
1245
+ /** For type='asset': the sha256 hash. For legacy file URIs: '<wsId>/<path>'. */
1246
+ rest: string;
1247
+ /** Convenience parses for type='file' and for workspace-form 'asset'. */
1248
+ workspaceId?: string;
1249
+ filePath?: string;
1250
+ }
1251
+ /**
1252
+ * Find every recognized `prismer://...` reference in a string.
1253
+ * Only `asset` and `file` types are recognized — other types (memory,
1254
+ * context, conversation, evolution, task, pair) pass through untouched.
1255
+ */
1256
+ declare function parseUris(text: string): ParsedPrismerUri[];
1257
+ interface UriResolverOptions {
1258
+ db: LocalDb;
1259
+ cloud: CloudClient;
1260
+ assetCache: AssetCache;
1261
+ }
1262
+ declare class UriResolver {
1263
+ private readonly db;
1264
+ private readonly cloud;
1265
+ private readonly assetCache;
1266
+ constructor(opts: UriResolverOptions);
1267
+ /**
1268
+ * Resolve a single URI to a local file path. Throws on auth/4xx;
1269
+ * caller decides whether to leave the URI in place (best-effort) or fail.
1270
+ */
1271
+ resolveOne(uri: ParsedPrismerUri, opts?: {
1272
+ signal?: AbortSignal;
1273
+ }): Promise<string>;
1274
+ /**
1275
+ * Walk a string, replace every `prismer://(asset|file)/...` and
1276
+ * `https://…` / `http://…` URL with `file://<localPath>`.
1277
+ *
1278
+ * Unrecognized URIs pass through unchanged. Returns rewritten text, the
1279
+ * list of pinned hashes, and one observation per http(s) URL the resolver
1280
+ * attempted (success + error both surface) so the dispatch can include
1281
+ * them in `reply.assetObservability`.
1282
+ *
1283
+ * `urlCache` lets the caller dedupe URL fetches across multiple rewrite
1284
+ * calls within a single dispatch (e.g. prompt + each context entry).
1285
+ * Pass the same Map instance to every rewrite() / rewriteAll() call.
1286
+ */
1287
+ rewrite(text: string, opts?: {
1288
+ pin?: boolean;
1289
+ signal?: AbortSignal;
1290
+ /** L5: opt out of http(s) URL fetching for this string (e.g. memory/goal text). */
1291
+ fetchUrls?: boolean;
1292
+ /** L5: shared per-dispatch dedup map (originalUrl → cached resolution). */
1293
+ urlCache?: Map<string, UrlResolution>;
1294
+ /** L5: append url observations here (caller-owned array). */
1295
+ urlObservations?: AssetDispatchObservation[];
1296
+ }): Promise<{
1297
+ text: string;
1298
+ resolvedHashes: string[];
1299
+ }>;
1300
+ /** Bulk-rewrite an array of strings (e.g. context entries' content). */
1301
+ rewriteAll(texts: string[], opts?: {
1302
+ pin?: boolean;
1303
+ signal?: AbortSignal;
1304
+ fetchUrls?: boolean;
1305
+ urlCache?: Map<string, UrlResolution>;
1306
+ urlObservations?: AssetDispatchObservation[];
1307
+ }): Promise<{
1308
+ texts: string[];
1309
+ resolvedHashes: string[];
1310
+ }>;
1311
+ private lookupFile;
1312
+ }
1313
+ /**
1314
+ * L5: per-dispatch resolution record for a fetched http(s) URL. The same
1315
+ * record is reused across every reference to the URL in this dispatch
1316
+ * (prompt + N context entries) so we resolve once even if the URL appears
1317
+ * many times.
1318
+ */
1319
+ interface UrlResolution {
1320
+ hash: string;
1321
+ localPath: string;
1322
+ sizeBytes: number;
1323
+ mime: string | null;
1324
+ finalUrl: string;
1325
+ durationMs: number;
1326
+ }
1327
+ /**
1328
+ * Extract http(s) URLs from a string. Each match has trailing punctuation
1329
+ * stripped so callers can replace the exact match in the source text.
1330
+ * Duplicates are de-duped: the first occurrence wins.
1331
+ */
1332
+ declare function extractHttpUrls(text: string): string[];
1333
+
1257
1334
  interface OutboxWatcherOptions {
1258
1335
  /**
1259
1336
  * Default directory to watch when no setActiveTask has narrowed it.
@@ -2198,4 +2275,4 @@ declare const codexAdapter: AdapterDef;
2198
2275
  declare function buildProgram(): Command;
2199
2276
  declare function runCli(argv?: string[]): Promise<void>;
2200
2277
 
2201
- export { type AcquireResult, type AdapterDef, type AdapterKind, AdapterRegistry, type AdapterService, type AgentChangedPayload, type AgentDispatchReplyAttachment, type AgentDispatchReplyPayload, type AgentDispatchReplyStatus, type AgentDispatchRequest, type AgentDispatchResponse, type AgentHostDeclarePayload, type AgentProfile, type AgentProfileChangedPayload, type AgentStatusChangedPayload, AssetCache, type AssetCacheOptions, type AssetChangedPayload, type AssetDispatchObservation, type AssetDispatchStrategy, type AssetRef, BUILTIN_ROLE_TEMPLATES, type CachedAsset, type ClaudeCodeConfig, CloudClient, type CloudClientOptions, CloudError, type CloudResponse, type CodexConfig, type Config, type ConfigPaths, ConfigSchema, type DispatchDeps, type Envelope, type FlushFn, type FlushResult, type HealthStatus, type HermesProfileConfig, type HostAckedPayload, type HostedAgentDeclaration, type IMAgentStatus, type IMWSMessage, type LocalDb, LocalServer, type LocalServerOptions, type LocalServerState, type MessageDispatchAgent, type MessageDispatchDeps, type MessageDispatchHandle, type MessageDispatchTaskInput, type NormalizedContent, type OpenClawProfileConfig, type PairOptions, type PairResult, type ParseClaim, ParseClaimController, type ParseClaimControllerOptions, type ParsedPrismerUri, type PrismerUriType, type RoleTemplate, Runner, type RunnerOptions, ServicePool, type SyncOperation, SyncQueue, type SyncQueueRow, type SyncResourceType, type SyncStatus, SyncWorker, type SyncWorkerOptions, TARGET_SCHEMA_VERSION, type TaskCancelPayload, type TaskDispatchContextEntry, type TaskDispatchProgressPayload, type TaskDispatchReplyPayload, type TaskDispatchRequestPayload, type TaskInput, type TaskResult, UriResolver, type UriResolverOptions, type ValidationResult, WS_CLOSE, type WorkspaceChangedPayload, type WorkspaceFileBinding, type WorkspaceFileChangedPayload, WorkspaceMirror, type WorkspaceMirrorOptions, WsClient, type WsClientOptions, buildProgram, claudeCodeAdapter, codexAdapter, composePrompt, configExists, currentSchemaVersion, deriveWsUrl, envelope, getRoleTemplate, handleAgentMessageDispatch, handleDispatch, hermesAdapter, isDaemonId, listRoleTemplates, loadConfig, newDaemonId, nextBackoffMs, openLocalDb, openclawAdapter, pair, parseCodexOutput, parseUris, resolvePaths, runCli, runMigrations, saveConfig };
2278
+ export { type AcquireResult, type AdapterDef, type AdapterKind, AdapterRegistry, type AdapterService, type AgentChangedPayload, type AgentDispatchReplyAttachment, type AgentDispatchReplyPayload, type AgentDispatchReplyStatus, type AgentDispatchRequest, type AgentDispatchResponse, type AgentHostDeclarePayload, type AgentProfile, type AgentProfileChangedPayload, type AgentStatusChangedPayload, AssetCache, type AssetCacheOptions, type AssetChangedPayload, type AssetDispatchObservation, type AssetDispatchStrategy, type AssetRef, BUILTIN_ROLE_TEMPLATES, type CachedAsset, type ClaudeCodeConfig, CloudClient, type CloudClientOptions, CloudError, type CloudResponse, type CodexConfig, type Config, type ConfigPaths, ConfigSchema, type DispatchDeps, type Envelope, type FlushFn, type FlushResult, type HealthStatus, type HermesProfileConfig, type HostAckedPayload, type HostedAgentDeclaration, type IMAgentStatus, type IMWSMessage, type LocalDb, LocalServer, type LocalServerOptions, type LocalServerState, type MessageDispatchAgent, type MessageDispatchDeps, type MessageDispatchHandle, type MessageDispatchTaskInput, type NormalizedContent, type OpenClawProfileConfig, type PairOptions, type PairResult, type ParseClaim, ParseClaimController, type ParseClaimControllerOptions, type ParsedPrismerUri, type PrismerUriType, type RoleTemplate, Runner, type RunnerOptions, ServicePool, type SyncOperation, SyncQueue, type SyncQueueRow, type SyncResourceType, type SyncStatus, SyncWorker, type SyncWorkerOptions, TARGET_SCHEMA_VERSION, type TaskCancelPayload, type TaskDispatchContextEntry, type TaskDispatchProgressPayload, type TaskDispatchReplyPayload, type TaskDispatchRequestPayload, type TaskInput, type TaskResult, UriResolver, type UriResolverOptions, type UrlResolution, type ValidationResult, WS_CLOSE, type WorkspaceChangedPayload, type WorkspaceFileBinding, type WorkspaceFileChangedPayload, WorkspaceMirror, type WorkspaceMirrorOptions, WsClient, type WsClientOptions, buildProgram, claudeCodeAdapter, codexAdapter, composePrompt, configExists, currentSchemaVersion, deriveWsUrl, envelope, extractHttpUrls, getRoleTemplate, handleAgentMessageDispatch, handleDispatch, hermesAdapter, isDaemonId, listRoleTemplates, loadConfig, newDaemonId, nextBackoffMs, openLocalDb, openclawAdapter, pair, parseCodexOutput, parseUris, resolvePaths, runCli, runMigrations, saveConfig };
package/dist/index.d.ts CHANGED
@@ -865,6 +865,38 @@ declare class AssetCache {
865
865
  signal?: AbortSignal;
866
866
  assetId?: string;
867
867
  }): Promise<CachedAsset>;
868
+ /**
869
+ * Fetch a public http(s) URL, content-hash dedup, cache locally.
870
+ *
871
+ * Mirrors `getOrFetch` (cache key = sha256 of body bytes), but the input
872
+ * is a URL whose hash we don't know up front. The fetcher applies:
873
+ *
874
+ * - SSRF guard (resolve hostname, reject loopback / RFC1918 / link-local
875
+ * / cloud-metadata / IPv6 ULA + link-local). Cross-host redirects
876
+ * re-validate the new host before each hop.
877
+ * - manual redirect handling (max 3 hops).
878
+ * - hard timeout (default 15 s, override via env
879
+ * `PRISMER_URL_FETCH_TIMEOUT_MS`).
880
+ * - streaming body read with abort-at-limit (default 5 MiB, override
881
+ * via env `PRISMER_URL_FETCH_MAX_BYTES`). Truncated bodies are NOT
882
+ * cached.
883
+ * - non-2xx → throws (caller should leave the URL in place and emit
884
+ * an `error` observation).
885
+ *
886
+ * On success returns { cached, finalUrl, durationMs }; the caller can
887
+ * pin / unpin the hash like any other asset.
888
+ */
889
+ getOrFetchUrl(url: string, opts?: {
890
+ signal?: AbortSignal;
891
+ userAgent?: string;
892
+ maxBytes?: number;
893
+ timeoutMs?: number;
894
+ maxRedirects?: number;
895
+ }): Promise<{
896
+ cached: CachedAsset;
897
+ finalUrl: string;
898
+ durationMs: number;
899
+ }>;
868
900
  /** Insert an already-on-disk asset into the cache (e.g., asset just produced by adapter). */
869
901
  registerLocal(hash: string, localPath: string, mime?: string): CachedAsset;
870
902
  /** Total bytes across all rows (incl. pinned). */
@@ -1022,68 +1054,6 @@ declare class ParseClaimController {
1022
1054
  }): HeartbeatHandle;
1023
1055
  }
1024
1056
 
1025
- type PrismerUriType = 'asset' | 'file';
1026
- interface ParsedPrismerUri {
1027
- /** Original full URI string. */
1028
- raw: string;
1029
- /**
1030
- * Owner segment for legacy `prismer://<owner>/...` form (informational,
1031
- * not ACL-checked). For `prismer://workspace/<wid>/...` this is the
1032
- * literal string 'workspace' — prefer `workspaceId` instead.
1033
- */
1034
- owner: string;
1035
- type: PrismerUriType;
1036
- /** For type='asset': the sha256 hash. For legacy file URIs: '<wsId>/<path>'. */
1037
- rest: string;
1038
- /** Convenience parses for type='file' and for workspace-form 'asset'. */
1039
- workspaceId?: string;
1040
- filePath?: string;
1041
- }
1042
- /**
1043
- * Find every recognized `prismer://...` reference in a string.
1044
- * Only `asset` and `file` types are recognized — other types (memory,
1045
- * context, conversation, evolution, task, pair) pass through untouched.
1046
- */
1047
- declare function parseUris(text: string): ParsedPrismerUri[];
1048
- interface UriResolverOptions {
1049
- db: LocalDb;
1050
- cloud: CloudClient;
1051
- assetCache: AssetCache;
1052
- }
1053
- declare class UriResolver {
1054
- private readonly db;
1055
- private readonly cloud;
1056
- private readonly assetCache;
1057
- constructor(opts: UriResolverOptions);
1058
- /**
1059
- * Resolve a single URI to a local file path. Throws on auth/4xx;
1060
- * caller decides whether to leave the URI in place (best-effort) or fail.
1061
- */
1062
- resolveOne(uri: ParsedPrismerUri, opts?: {
1063
- signal?: AbortSignal;
1064
- }): Promise<string>;
1065
- /**
1066
- * Walk a string, replace every `prismer://(asset|file)/...` with `file://<localPath>`.
1067
- * Unrecognized URIs pass through. Returns rewritten text + the list of pinned hashes.
1068
- */
1069
- rewrite(text: string, opts?: {
1070
- pin?: boolean;
1071
- signal?: AbortSignal;
1072
- }): Promise<{
1073
- text: string;
1074
- resolvedHashes: string[];
1075
- }>;
1076
- /** Bulk-rewrite an array of strings (e.g. context entries' content). */
1077
- rewriteAll(texts: string[], opts?: {
1078
- pin?: boolean;
1079
- signal?: AbortSignal;
1080
- }): Promise<{
1081
- texts: string[];
1082
- resolvedHashes: string[];
1083
- }>;
1084
- private lookupFile;
1085
- }
1086
-
1087
1057
  type IMAgentStatus = 'online' | 'busy' | 'idle' | 'offline';
1088
1058
  interface HostedAgentDeclaration {
1089
1059
  imUserId: string;
@@ -1185,15 +1155,22 @@ interface TaskDispatchProgressPayload {
1185
1155
  detail?: Record<string, unknown>;
1186
1156
  }
1187
1157
  /** Wave-8 W1: how the daemon handled a single AssetRef. */
1188
- type AssetDispatchStrategy = 'inline-text' | 'inline-text-truncated' | 'uri-only' | 'error';
1158
+ type AssetDispatchStrategy = 'inline-text' | 'inline-text-truncated' | 'uri-only' | 'fetched-https' | 'error';
1189
1159
  interface AssetDispatchObservation {
1190
- assetId: string;
1160
+ /** AssetRef.assetId for cloud-attached refs; undefined for L5 https fetches. */
1161
+ assetId?: string;
1191
1162
  contentHash: string;
1192
1163
  mime: string | null;
1193
1164
  sizeBytes: number | null;
1194
1165
  strategy: AssetDispatchStrategy;
1195
1166
  inlinedBytes?: number;
1196
1167
  error?: string;
1168
+ /** L5: original URL the user wrote in the prompt. */
1169
+ originalUrl?: string;
1170
+ /** L5: post-redirect URL the body was actually downloaded from. */
1171
+ finalUrl?: string;
1172
+ /** L5: end-to-end fetch duration in ms (DNS + connect + body read). */
1173
+ durationMs?: number;
1197
1174
  }
1198
1175
  interface TaskDispatchReplyPayload {
1199
1176
  taskId: string;
@@ -1254,6 +1231,106 @@ interface AssetChangedPayload {
1254
1231
  revision?: number;
1255
1232
  }
1256
1233
 
1234
+ type PrismerUriType = 'asset' | 'file';
1235
+ interface ParsedPrismerUri {
1236
+ /** Original full URI string. */
1237
+ raw: string;
1238
+ /**
1239
+ * Owner segment for legacy `prismer://<owner>/...` form (informational,
1240
+ * not ACL-checked). For `prismer://workspace/<wid>/...` this is the
1241
+ * literal string 'workspace' — prefer `workspaceId` instead.
1242
+ */
1243
+ owner: string;
1244
+ type: PrismerUriType;
1245
+ /** For type='asset': the sha256 hash. For legacy file URIs: '<wsId>/<path>'. */
1246
+ rest: string;
1247
+ /** Convenience parses for type='file' and for workspace-form 'asset'. */
1248
+ workspaceId?: string;
1249
+ filePath?: string;
1250
+ }
1251
+ /**
1252
+ * Find every recognized `prismer://...` reference in a string.
1253
+ * Only `asset` and `file` types are recognized — other types (memory,
1254
+ * context, conversation, evolution, task, pair) pass through untouched.
1255
+ */
1256
+ declare function parseUris(text: string): ParsedPrismerUri[];
1257
+ interface UriResolverOptions {
1258
+ db: LocalDb;
1259
+ cloud: CloudClient;
1260
+ assetCache: AssetCache;
1261
+ }
1262
+ declare class UriResolver {
1263
+ private readonly db;
1264
+ private readonly cloud;
1265
+ private readonly assetCache;
1266
+ constructor(opts: UriResolverOptions);
1267
+ /**
1268
+ * Resolve a single URI to a local file path. Throws on auth/4xx;
1269
+ * caller decides whether to leave the URI in place (best-effort) or fail.
1270
+ */
1271
+ resolveOne(uri: ParsedPrismerUri, opts?: {
1272
+ signal?: AbortSignal;
1273
+ }): Promise<string>;
1274
+ /**
1275
+ * Walk a string, replace every `prismer://(asset|file)/...` and
1276
+ * `https://…` / `http://…` URL with `file://<localPath>`.
1277
+ *
1278
+ * Unrecognized URIs pass through unchanged. Returns rewritten text, the
1279
+ * list of pinned hashes, and one observation per http(s) URL the resolver
1280
+ * attempted (success + error both surface) so the dispatch can include
1281
+ * them in `reply.assetObservability`.
1282
+ *
1283
+ * `urlCache` lets the caller dedupe URL fetches across multiple rewrite
1284
+ * calls within a single dispatch (e.g. prompt + each context entry).
1285
+ * Pass the same Map instance to every rewrite() / rewriteAll() call.
1286
+ */
1287
+ rewrite(text: string, opts?: {
1288
+ pin?: boolean;
1289
+ signal?: AbortSignal;
1290
+ /** L5: opt out of http(s) URL fetching for this string (e.g. memory/goal text). */
1291
+ fetchUrls?: boolean;
1292
+ /** L5: shared per-dispatch dedup map (originalUrl → cached resolution). */
1293
+ urlCache?: Map<string, UrlResolution>;
1294
+ /** L5: append url observations here (caller-owned array). */
1295
+ urlObservations?: AssetDispatchObservation[];
1296
+ }): Promise<{
1297
+ text: string;
1298
+ resolvedHashes: string[];
1299
+ }>;
1300
+ /** Bulk-rewrite an array of strings (e.g. context entries' content). */
1301
+ rewriteAll(texts: string[], opts?: {
1302
+ pin?: boolean;
1303
+ signal?: AbortSignal;
1304
+ fetchUrls?: boolean;
1305
+ urlCache?: Map<string, UrlResolution>;
1306
+ urlObservations?: AssetDispatchObservation[];
1307
+ }): Promise<{
1308
+ texts: string[];
1309
+ resolvedHashes: string[];
1310
+ }>;
1311
+ private lookupFile;
1312
+ }
1313
+ /**
1314
+ * L5: per-dispatch resolution record for a fetched http(s) URL. The same
1315
+ * record is reused across every reference to the URL in this dispatch
1316
+ * (prompt + N context entries) so we resolve once even if the URL appears
1317
+ * many times.
1318
+ */
1319
+ interface UrlResolution {
1320
+ hash: string;
1321
+ localPath: string;
1322
+ sizeBytes: number;
1323
+ mime: string | null;
1324
+ finalUrl: string;
1325
+ durationMs: number;
1326
+ }
1327
+ /**
1328
+ * Extract http(s) URLs from a string. Each match has trailing punctuation
1329
+ * stripped so callers can replace the exact match in the source text.
1330
+ * Duplicates are de-duped: the first occurrence wins.
1331
+ */
1332
+ declare function extractHttpUrls(text: string): string[];
1333
+
1257
1334
  interface OutboxWatcherOptions {
1258
1335
  /**
1259
1336
  * Default directory to watch when no setActiveTask has narrowed it.
@@ -2198,4 +2275,4 @@ declare const codexAdapter: AdapterDef;
2198
2275
  declare function buildProgram(): Command;
2199
2276
  declare function runCli(argv?: string[]): Promise<void>;
2200
2277
 
2201
- export { type AcquireResult, type AdapterDef, type AdapterKind, AdapterRegistry, type AdapterService, type AgentChangedPayload, type AgentDispatchReplyAttachment, type AgentDispatchReplyPayload, type AgentDispatchReplyStatus, type AgentDispatchRequest, type AgentDispatchResponse, type AgentHostDeclarePayload, type AgentProfile, type AgentProfileChangedPayload, type AgentStatusChangedPayload, AssetCache, type AssetCacheOptions, type AssetChangedPayload, type AssetDispatchObservation, type AssetDispatchStrategy, type AssetRef, BUILTIN_ROLE_TEMPLATES, type CachedAsset, type ClaudeCodeConfig, CloudClient, type CloudClientOptions, CloudError, type CloudResponse, type CodexConfig, type Config, type ConfigPaths, ConfigSchema, type DispatchDeps, type Envelope, type FlushFn, type FlushResult, type HealthStatus, type HermesProfileConfig, type HostAckedPayload, type HostedAgentDeclaration, type IMAgentStatus, type IMWSMessage, type LocalDb, LocalServer, type LocalServerOptions, type LocalServerState, type MessageDispatchAgent, type MessageDispatchDeps, type MessageDispatchHandle, type MessageDispatchTaskInput, type NormalizedContent, type OpenClawProfileConfig, type PairOptions, type PairResult, type ParseClaim, ParseClaimController, type ParseClaimControllerOptions, type ParsedPrismerUri, type PrismerUriType, type RoleTemplate, Runner, type RunnerOptions, ServicePool, type SyncOperation, SyncQueue, type SyncQueueRow, type SyncResourceType, type SyncStatus, SyncWorker, type SyncWorkerOptions, TARGET_SCHEMA_VERSION, type TaskCancelPayload, type TaskDispatchContextEntry, type TaskDispatchProgressPayload, type TaskDispatchReplyPayload, type TaskDispatchRequestPayload, type TaskInput, type TaskResult, UriResolver, type UriResolverOptions, type ValidationResult, WS_CLOSE, type WorkspaceChangedPayload, type WorkspaceFileBinding, type WorkspaceFileChangedPayload, WorkspaceMirror, type WorkspaceMirrorOptions, WsClient, type WsClientOptions, buildProgram, claudeCodeAdapter, codexAdapter, composePrompt, configExists, currentSchemaVersion, deriveWsUrl, envelope, getRoleTemplate, handleAgentMessageDispatch, handleDispatch, hermesAdapter, isDaemonId, listRoleTemplates, loadConfig, newDaemonId, nextBackoffMs, openLocalDb, openclawAdapter, pair, parseCodexOutput, parseUris, resolvePaths, runCli, runMigrations, saveConfig };
2278
+ export { type AcquireResult, type AdapterDef, type AdapterKind, AdapterRegistry, type AdapterService, type AgentChangedPayload, type AgentDispatchReplyAttachment, type AgentDispatchReplyPayload, type AgentDispatchReplyStatus, type AgentDispatchRequest, type AgentDispatchResponse, type AgentHostDeclarePayload, type AgentProfile, type AgentProfileChangedPayload, type AgentStatusChangedPayload, AssetCache, type AssetCacheOptions, type AssetChangedPayload, type AssetDispatchObservation, type AssetDispatchStrategy, type AssetRef, BUILTIN_ROLE_TEMPLATES, type CachedAsset, type ClaudeCodeConfig, CloudClient, type CloudClientOptions, CloudError, type CloudResponse, type CodexConfig, type Config, type ConfigPaths, ConfigSchema, type DispatchDeps, type Envelope, type FlushFn, type FlushResult, type HealthStatus, type HermesProfileConfig, type HostAckedPayload, type HostedAgentDeclaration, type IMAgentStatus, type IMWSMessage, type LocalDb, LocalServer, type LocalServerOptions, type LocalServerState, type MessageDispatchAgent, type MessageDispatchDeps, type MessageDispatchHandle, type MessageDispatchTaskInput, type NormalizedContent, type OpenClawProfileConfig, type PairOptions, type PairResult, type ParseClaim, ParseClaimController, type ParseClaimControllerOptions, type ParsedPrismerUri, type PrismerUriType, type RoleTemplate, Runner, type RunnerOptions, ServicePool, type SyncOperation, SyncQueue, type SyncQueueRow, type SyncResourceType, type SyncStatus, SyncWorker, type SyncWorkerOptions, TARGET_SCHEMA_VERSION, type TaskCancelPayload, type TaskDispatchContextEntry, type TaskDispatchProgressPayload, type TaskDispatchReplyPayload, type TaskDispatchRequestPayload, type TaskInput, type TaskResult, UriResolver, type UriResolverOptions, type UrlResolution, type ValidationResult, WS_CLOSE, type WorkspaceChangedPayload, type WorkspaceFileBinding, type WorkspaceFileChangedPayload, WorkspaceMirror, type WorkspaceMirrorOptions, WsClient, type WsClientOptions, buildProgram, claudeCodeAdapter, codexAdapter, composePrompt, configExists, currentSchemaVersion, deriveWsUrl, envelope, extractHttpUrls, getRoleTemplate, handleAgentMessageDispatch, handleDispatch, hermesAdapter, isDaemonId, listRoleTemplates, loadConfig, newDaemonId, nextBackoffMs, openLocalDb, openclawAdapter, pair, parseCodexOutput, parseUris, resolvePaths, runCli, runMigrations, saveConfig };