@sema-agent/client-core 0.97.1 → 0.99.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/CHANGELOG.md +607 -0
- package/README.md +96 -46
- package/dist/adapt/arms.d.ts +1 -0
- package/dist/adapt/arms.js +188 -53
- package/dist/adapt/ids.d.ts +12 -1
- package/dist/adapt/ids.js +59 -8
- package/dist/adapt/instanceLedger.d.ts +50 -0
- package/dist/adapt/instanceLedger.js +147 -0
- package/dist/adapt/panelTasks.d.ts +1 -1
- package/dist/adapt/panelTasks.js +2 -2
- package/dist/adapt/textStream.d.ts +1 -0
- package/dist/adapt/textStream.js +24 -7
- package/dist/adapt/toolCards.d.ts +27 -5
- package/dist/adapt/toolCards.js +39 -6
- package/dist/adapt/wireShapes.js +6 -2
- package/dist/adapt.d.ts +2 -0
- package/dist/adapt.js +8 -3
- package/dist/adapter/activeRunSelfHeal.d.ts +9 -3
- package/dist/adapter/activeRunSelfHeal.js +205 -313
- package/dist/adapter/downstream/eventToSdkMessage.d.ts +2 -5
- package/dist/adapter/downstream/eventToSdkMessage.js +77 -36
- package/dist/adapter/downstream/terminalToSdkResult.js +11 -4
- package/dist/adapter/downstream/turnUsageToModelUsage.d.ts +5 -2
- package/dist/adapter/downstream/turnUsageToModelUsage.js +2 -0
- package/dist/adapter/runStream.js +79 -48
- package/dist/adapter/types.d.ts +4 -4
- package/dist/adapter/types.js +2 -1
- package/dist/agentSession/backgroundView.js +2 -1
- package/dist/agentSession/engineAgentRegistryRead.d.ts +2 -2
- package/dist/agentSession/engineAgentRegistryRead.js +12 -13
- package/dist/agentSession/engineSessionBackgroundStop.js +16 -8
- package/dist/agentsWireCaps.d.ts +8 -11
- package/dist/agentsWireCaps.js +196 -194
- package/dist/approvalDecidedByCapability.d.ts +0 -4
- package/dist/approvalDecidedByCapability.js +0 -6
- package/dist/approvalsStreamLiveCapability.d.ts +0 -4
- package/dist/approvalsStreamLiveCapability.js +0 -6
- package/dist/assistantInbox.d.ts +34 -0
- package/dist/assistantInbox.js +118 -0
- package/dist/centerWiringCapability.js +9 -1
- package/dist/clientSlice.d.ts +0 -9
- package/dist/clientSlice.js +0 -3
- package/dist/cloudConfigWireCaps.d.ts +5 -3
- package/dist/cloudConfigWireCaps.js +106 -64
- package/dist/compensations.js +1 -1
- package/dist/connectorStatus.d.ts +21 -0
- package/dist/connectorStatus.js +112 -0
- package/dist/controlRouter.d.ts +18 -3
- package/dist/controlRouter.js +106 -67
- package/dist/coreValuePorts.d.ts +29 -4
- package/dist/coreValuePorts.js +10 -0
- package/dist/corruptSessionCopy.d.ts +2 -1
- package/dist/corruptSessionCopy.js +3 -3
- package/dist/decideReceipt.d.ts +2 -2
- package/dist/decideReceipt.js +5 -2
- package/dist/declared/supportFloorDeclared.js +3 -3
- package/dist/detachWire.js +3 -2
- package/dist/deviceExecutorManagementCapability.d.ts +0 -4
- package/dist/deviceExecutorManagementCapability.js +0 -6
- package/dist/deviceRebind.d.ts +49 -1
- package/dist/deviceRebind.js +221 -3
- package/dist/devicesFace.d.ts +34 -0
- package/dist/devicesFace.js +90 -0
- package/dist/displayUntrusted.d.ts +2 -0
- package/dist/displayUntrusted.js +253 -76
- package/dist/engineAgentAbsence.d.ts +1 -1
- package/dist/engineAgentPanelStore.d.ts +12 -4
- package/dist/engineAgentPanelStore.js +16 -11
- package/dist/engineCapReader.d.ts +2 -5
- package/dist/engineCapReader.js +8 -10
- package/dist/engineCapsCache.d.ts +12 -0
- package/dist/engineCapsCache.js +76 -18
- package/dist/engineCapsChange.d.ts +2 -0
- package/dist/engineCapsChange.js +9 -0
- package/dist/engineClosedSets.d.ts +1 -0
- package/dist/engineClosedSets.js +4 -1
- package/dist/engineErrorCodes.d.ts +11 -3
- package/dist/engineErrorCodes.js +11 -8
- package/dist/engineIdentity.d.ts +1 -0
- package/dist/engineIdentity.js +8 -0
- package/dist/engineRowRef.d.ts +28 -0
- package/dist/engineRowRef.js +114 -0
- package/dist/engineSessionMessages.d.ts +68 -0
- package/dist/engineSessionMessages.js +370 -0
- package/dist/engineTargetSeat.d.ts +27 -0
- package/dist/engineTargetSeat.js +199 -0
- package/dist/engineToolDirectory.d.ts +0 -9
- package/dist/engineToolDirectory.js +1 -94
- package/dist/engineUrl.d.ts +18 -0
- package/dist/engineUrl.js +52 -0
- package/dist/engineWireFor.js +3 -8
- package/dist/env/uiLanguage.d.ts +11 -1
- package/dist/env/uiLanguage.js +38 -2
- package/dist/eventLeg.d.ts +100 -0
- package/dist/eventLeg.js +305 -0
- package/dist/executionLaneCapability.d.ts +0 -4
- package/dist/executionLaneCapability.js +3 -16
- package/dist/fileHistoryCaptureCapability.d.ts +2 -5
- package/dist/fileHistoryCaptureCapability.js +13 -21
- package/dist/fileHistoryLegNotice.d.ts +2 -1
- package/dist/fileHistoryLegNotice.js +3 -3
- package/dist/fleet/fleetLedger.d.ts +0 -3
- package/dist/fleet/fleetLedger.js +21 -36
- package/dist/fleet/fleetProjection.d.ts +2 -2
- package/dist/fleet/fleetProjection.js +10 -8
- package/dist/frameBinding.d.ts +8 -0
- package/dist/frameBinding.js +35 -0
- package/dist/gateFailureCodes.d.ts +2 -0
- package/dist/gateFailureCodes.js +15 -0
- package/dist/gateOutcome.d.ts +3 -1
- package/dist/gateOutcome.js +41 -8
- package/dist/gateVocabulary.d.ts +10 -4
- package/dist/gateVocabulary.js +107 -47
- package/dist/generated/engineAskFaceTables.js +2 -2
- package/dist/generated/engineFactTables.d.ts +22 -3
- package/dist/generated/engineFactTables.js +51 -4
- package/dist/generated/engineNoticeTables.js +18 -3
- package/dist/generated/settingsSchemaFns.d.ts +6 -0
- package/dist/generated/settingsSchemaFns.js +57 -0
- package/dist/generated/settingsSchemaHooksClassifier.d.ts +2 -0
- package/dist/generated/settingsSchemaHooksClassifier.js +254 -0
- package/dist/generated/settingsSchemaTables.d.ts +1 -0
- package/dist/generated/settingsSchemaTables.js +4 -0
- package/dist/generated/settingsSchemaTypes.d.ts +105 -0
- package/dist/generated/settingsSchemaTypes.js +1 -0
- package/dist/generated/toolNameTables.d.ts +1 -0
- package/dist/generated/toolNameTables.js +1 -0
- package/dist/hitl/allowRuleShadow.d.ts +8 -2
- package/dist/hitl/allowRuleShadow.js +36 -29
- package/dist/hitl/approvalCardReading.d.ts +15 -0
- package/dist/hitl/approvalCardReading.js +154 -0
- package/dist/hitl/approvalCardReasons.d.ts +14 -0
- package/dist/hitl/approvalCardReasons.js +119 -0
- package/dist/hitl/approvalHolds.d.ts +50 -15
- package/dist/hitl/approvalHolds.js +177 -27
- package/dist/hitl/approvalResolution.d.ts +51 -26
- package/dist/hitl/approvalResolution.js +86 -122
- package/dist/hitl/approvalsFeed.js +6 -18
- package/dist/hitl/askClassPair.d.ts +2 -0
- package/dist/hitl/askClassPair.js +17 -0
- package/dist/hitl/askGateWire.d.ts +20 -2
- package/dist/hitl/askGateWire.js +50 -1
- package/dist/hitl/askParkRowRouting.d.ts +5 -0
- package/dist/hitl/askParkRowRouting.js +32 -1
- package/dist/hitl/askSettlementLine.d.ts +28 -0
- package/dist/hitl/askSettlementLine.js +99 -0
- package/dist/hitl/automaticAnswerVerdict.d.ts +3 -2
- package/dist/hitl/automaticAnswerVerdict.js +29 -13
- package/dist/hitl/crashConverged.d.ts +11 -20
- package/dist/hitl/crashConverged.js +56 -0
- package/dist/hitl/crashConvergedNotice.d.ts +6 -3
- package/dist/hitl/crashConvergedNotice.js +48 -24
- package/dist/hitl/decisionConflict.js +3 -10
- package/dist/hitl/decisionRefusal.d.ts +40 -1
- package/dist/hitl/decisionRefusal.js +199 -42
- package/dist/hitl/frameRouter.d.ts +5 -2
- package/dist/hitl/frameRouter.js +27 -24
- package/dist/hitl/gateLedger.d.ts +2 -0
- package/dist/hitl/gateLedger.js +50 -13
- package/dist/hitl/hitlBridge.d.ts +2 -2
- package/dist/hitl/hitlBridge.js +13 -10
- package/dist/hitl/livePendingAsk.d.ts +3 -3
- package/dist/hitl/livePendingAsk.js +7 -18
- package/dist/hitl/parkResolver.d.ts +2 -24
- package/dist/hitl/parkResolver.js +61 -97
- package/dist/hitl/persistedRulesWire.d.ts +25 -0
- package/dist/hitl/persistedRulesWire.js +104 -2
- package/dist/hitl/planReviewWire.d.ts +31 -13
- package/dist/hitl/planReviewWire.js +120 -78
- package/dist/hitl/refusedToolNameProse.d.ts +0 -1
- package/dist/hitl/refusedToolNameProse.js +0 -3
- package/dist/hitl/replayedApproval.d.ts +4 -3
- package/dist/hitl/replayedApproval.js +7 -4
- package/dist/hitl/sessionPolicyDeliverable.d.ts +2 -0
- package/dist/hitl/sessionPolicyDeliverable.js +48 -7
- package/dist/hitl/sessionPolicyWire.d.ts +34 -21
- package/dist/hitl/sessionPolicyWire.js +179 -70
- package/dist/hitl/standingRows.d.ts +20 -2
- package/dist/hitl/standingRows.js +69 -8
- package/dist/hitl/suspendedReopen.d.ts +2 -1
- package/dist/hitl/suspendedReopen.js +7 -10
- package/dist/hitl/toolApprovalWire.d.ts +103 -156
- package/dist/hitl/toolApprovalWire.js +661 -411
- package/dist/hookMatcherVerdict.d.ts +6 -1
- package/dist/hookMatcherVerdict.js +14 -7
- package/dist/hooksWireCaps.d.ts +2 -2
- package/dist/hooksWireCaps.js +174 -81
- package/dist/host.d.ts +21 -0
- package/dist/hostTurnSettings.d.ts +71 -0
- package/dist/hostTurnSettings.js +291 -0
- package/dist/humanTurn.d.ts +14 -1
- package/dist/humanTurn.js +100 -12
- package/dist/humanTurnRead.d.ts +2 -0
- package/dist/humanTurnRead.js +22 -1
- package/dist/i18n/messages.en.d.ts +703 -0
- package/dist/i18n/messages.en.js +701 -0
- package/dist/i18n/messages.zh.d.ts +3 -0
- package/dist/i18n/messages.zh.js +837 -0
- package/dist/i18n/translate.d.ts +25 -0
- package/dist/i18n/translate.js +127 -0
- package/dist/index.d.ts +78 -29
- package/dist/index.js +54 -18
- package/dist/inheritEnvCapability.d.ts +32 -0
- package/dist/inheritEnvCapability.js +104 -0
- package/dist/inheritEnvWire.d.ts +3 -2
- package/dist/inheritEnvWire.js +12 -14
- package/dist/interactiveHalt.js +17 -6
- package/dist/liveModelCatalog.d.ts +3 -3
- package/dist/liveModelCatalog.js +15 -13
- package/dist/liveQuestionStore.d.ts +2 -21
- package/dist/mcpLiveness.d.ts +2 -1
- package/dist/mcpPanel.d.ts +10 -1
- package/dist/mcpPanel.js +40 -13
- package/dist/mcpProbeCapability.d.ts +2 -1
- package/dist/mcpProbeCapability.js +7 -11
- package/dist/mcpProbeWire.d.ts +9 -2
- package/dist/mcpProbeWire.js +6 -1
- package/dist/mcpWireCaps.d.ts +47 -2
- package/dist/mcpWireCaps.js +164 -16
- package/dist/memoryEntriesWire.d.ts +4 -9
- package/dist/memoryEntriesWire.js +5 -10
- package/dist/model/modelSupplyRules.d.ts +0 -2
- package/dist/model/modelSupplyRules.js +3 -12
- package/dist/model/modelsPolicy.d.ts +0 -5
- package/dist/model/modelsPolicy.js +6 -36
- package/dist/model/onboardJudgement.d.ts +93 -0
- package/dist/model/onboardJudgement.js +415 -0
- package/dist/model/subagentModelWord.d.ts +31 -0
- package/dist/model/subagentModelWord.js +261 -0
- package/dist/model/tierVocabulary.d.ts +2 -0
- package/dist/model/tierVocabulary.js +17 -5
- package/dist/modelCapabilityProbe.d.ts +64 -0
- package/dist/modelCapabilityProbe.js +600 -0
- package/dist/modelIdentityResolvability.d.ts +3 -0
- package/dist/modelIdentityResolvability.js +26 -17
- package/dist/notifications.d.ts +6 -0
- package/dist/notifications.js +71 -23
- package/dist/outputStyleSeatCapability.d.ts +0 -3
- package/dist/outputStyleSeatCapability.js +0 -3
- package/dist/ownKey.d.ts +22 -0
- package/dist/ownKey.js +94 -3
- package/dist/panelReduce.d.ts +21 -10
- package/dist/panelReduce.js +728 -550
- package/dist/panelStateHolder.d.ts +3 -7
- package/dist/panelStateHolder.js +14 -130
- package/dist/peerLaneCapability.d.ts +0 -4
- package/dist/peerLaneCapability.js +0 -6
- package/dist/permissionRuleIssue.js +2 -0
- package/dist/permissionRulesWriteCapability.d.ts +2 -5
- package/dist/permissionRulesWriteCapability.js +8 -12
- package/dist/permissionWireCaps.d.ts +2 -2
- package/dist/permissionWireCaps.js +2 -0
- package/dist/permissionsAllowGrantCapability.d.ts +0 -4
- package/dist/permissionsAllowGrantCapability.js +0 -6
- package/dist/permissionsDeclaration.d.ts +0 -11
- package/dist/permissionsDeclaration.js +60 -53
- package/dist/pluginHooksWire.d.ts +46 -3
- package/dist/pluginHooksWire.js +219 -16
- package/dist/preemptWire.d.ts +44 -0
- package/dist/preemptWire.js +83 -0
- package/dist/printModelStatus.d.ts +63 -0
- package/dist/printModelStatus.js +155 -0
- package/dist/printToolResultFrame.js +15 -4
- package/dist/replayBody.d.ts +3 -0
- package/dist/replayBody.js +14 -0
- package/dist/request/taskRequest.d.ts +11 -6
- package/dist/request/taskRequest.js +112 -19
- package/dist/resumeRefusalCopy.d.ts +13 -9
- package/dist/resumeRefusalCopy.js +81 -118
- package/dist/retryStatus.d.ts +45 -0
- package/dist/retryStatus.js +185 -1
- package/dist/rewindArchiveCapability.d.ts +0 -4
- package/dist/rewindArchiveCapability.js +2 -10
- package/dist/rewindArchiveReading.d.ts +0 -1
- package/dist/rewindArchiveReading.js +0 -3
- package/dist/runCancelContext.d.ts +2 -1
- package/dist/runCancelContext.js +4 -2
- package/dist/runReattachPolicy.d.ts +31 -0
- package/dist/runReattachPolicy.js +46 -0
- package/dist/runTerminal.d.ts +3 -6
- package/dist/runTerminal.js +8 -9
- package/dist/sandboxWire.d.ts +3 -1
- package/dist/sandboxWire.js +76 -27
- package/dist/scenarioRefusal.d.ts +9 -0
- package/dist/scenarioRefusal.js +111 -0
- package/dist/scenarioWire.js +1 -1
- package/dist/seam.d.ts +48 -2
- package/dist/seam.js +25 -4
- package/dist/seatContract.d.ts +311 -18
- package/dist/seatContract.js +824 -100
- package/dist/selfOrchestrationDenial.js +7 -19
- package/dist/sessionIdSegment.d.ts +6 -0
- package/dist/sessionIdSegment.js +24 -0
- package/dist/sessionMemoryStatus.js +6 -11
- package/dist/sessionPolicyCapability.d.ts +2 -5
- package/dist/sessionPolicyCapability.js +8 -12
- package/dist/sessionSyncFileHistoryCapability.d.ts +0 -3
- package/dist/sessionSyncFileHistoryCapability.js +0 -3
- package/dist/settingsHooksSalvage.d.ts +44 -0
- package/dist/settingsHooksSalvage.js +211 -0
- package/dist/skillToolListsCapability.d.ts +2 -4
- package/dist/skillToolListsCapability.js +8 -9
- package/dist/sqlEngineCapability.d.ts +0 -4
- package/dist/sqlEngineCapability.js +0 -6
- package/dist/sseIdleTriage.js +3 -2
- package/dist/steerPriorityCapability.d.ts +0 -3
- package/dist/steerPriorityCapability.js +0 -3
- package/dist/streamDrainingLegs.d.ts +4 -0
- package/dist/streamDrainingLegs.js +6 -1
- package/dist/subagent/engineCompactWire.d.ts +0 -1
- package/dist/subagent/engineCompactWire.js +7 -5
- package/dist/subagent/engineSubagentResume.js +15 -9
- package/dist/subagent/engineTaskHandleWire.js +4 -7
- package/dist/subagentContentStore.d.ts +3 -0
- package/dist/subagentContentStore.js +22 -10
- package/dist/submitReopen.d.ts +24 -0
- package/dist/submitReopen.js +75 -0
- package/dist/terminalStatuses.d.ts +3 -0
- package/dist/terminalStatuses.js +10 -2
- package/dist/toolHistoryMismatch.js +3 -2
- package/dist/toolResult.d.ts +10 -1
- package/dist/toolResult.js +34 -6
- package/dist/toolRoster.d.ts +3 -4
- package/dist/toolRoster.js +21 -22
- package/dist/turnFailurePresentation.d.ts +39 -0
- package/dist/turnFailurePresentation.js +402 -0
- package/dist/usageAnalytics.js +6 -11
- package/dist/userAttachmentEnvelope.d.ts +1 -0
- package/dist/userAttachmentEnvelope.js +37 -7
- package/dist/userAttachmentSeat.d.ts +21 -0
- package/dist/userAttachmentSeat.js +75 -0
- package/dist/userInvokedSkillsCapability.d.ts +11 -4
- package/dist/userInvokedSkillsCapability.js +31 -10
- package/dist/webSearchBackendCapability.d.ts +0 -4
- package/dist/webSearchBackendCapability.js +0 -6
- package/dist/wireErrorTriage.d.ts +7 -0
- package/dist/wireErrorTriage.js +26 -23
- package/dist/wireFailureShape.d.ts +62 -5
- package/dist/wireFailureShape.js +106 -5
- package/dist/wireRefusalCopy.d.ts +25 -3
- package/dist/wireRefusalCopy.js +74 -80
- package/dist/workflowsJournalCapability.d.ts +2 -5
- package/dist/workflowsJournalCapability.js +8 -12
- package/dist/writeProtectionCapability.d.ts +0 -4
- package/dist/writeProtectionCapability.js +0 -6
- package/docs/INTEGRATION-CLIENTS.md +1775 -56
- package/package.json +6 -5
- package/dist/attachmentSeatCapability.d.ts +0 -12
- package/dist/attachmentSeatCapability.js +0 -23
- package/dist/hitl/approvalOutcomeNote.d.ts +0 -10
- package/dist/hitl/approvalOutcomeNote.js +0 -29
- package/dist/sessionReadRedactionCapability.d.ts +0 -13
- package/dist/sessionReadRedactionCapability.js +0 -35
package/dist/displayUntrusted.js
CHANGED
|
@@ -243,6 +243,22 @@ function schemelessHostEnd(text, from) {
|
|
|
243
243
|
const c = text.charCodeAt(k);
|
|
244
244
|
return endsSchemelessHost(c) || c === 0x27 ? k : -1;
|
|
245
245
|
}
|
|
246
|
+
const MAX_PORT = 65535;
|
|
247
|
+
function authorityIsHostPort(text, from, to) {
|
|
248
|
+
if (to <= from || schemelessHostEnd(text.slice(0, to), from) !== to)
|
|
249
|
+
return false;
|
|
250
|
+
const colon = text.charCodeAt(from) === 0x5b ? text.indexOf(']:', from) + 1 : text.indexOf(':', from);
|
|
251
|
+
if (colon <= 0 || colon >= to)
|
|
252
|
+
return true;
|
|
253
|
+
const port = text.slice(colon + 1, to);
|
|
254
|
+
return port.length <= 5 && Number(port) <= MAX_PORT;
|
|
255
|
+
}
|
|
256
|
+
function fragmentTerminatorFrom(s, from) {
|
|
257
|
+
for (let k = from; k < s.length; k++)
|
|
258
|
+
if (endsUrlFragmentAt(s, k))
|
|
259
|
+
return true;
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
246
262
|
function valueCoreForJudging(value) {
|
|
247
263
|
if (value.length === 0 || isMarker(value))
|
|
248
264
|
return '';
|
|
@@ -315,33 +331,63 @@ function pathCandidates(src, base, path, opaqueSegments, edits, soft) {
|
|
|
315
331
|
pos += segment.length + 1;
|
|
316
332
|
}
|
|
317
333
|
}
|
|
318
|
-
function
|
|
319
|
-
const
|
|
320
|
-
const schemeEnd = token.indexOf('://') + '://'.length;
|
|
321
|
-
const scheme = token.slice(0, schemeEnd);
|
|
322
|
-
const rest = token.slice(schemeEnd);
|
|
334
|
+
function addressCandidates(src, from, end, opaqueSegments, edits, regions, soft, byShape = false, whole = false, hostRegion = whole) {
|
|
335
|
+
const rest = src.slice(from, end);
|
|
323
336
|
const authorityEnd = rest.search(/[/?#]/);
|
|
324
337
|
const authority = authorityEnd === -1 ? rest : rest.slice(0, authorityEnd);
|
|
325
|
-
const tailStart =
|
|
326
|
-
const tail =
|
|
338
|
+
const tailStart = from + authority.length;
|
|
339
|
+
const tail = src.slice(tailStart, end);
|
|
327
340
|
const at = authority.lastIndexOf('@');
|
|
328
341
|
if (at !== -1 && !userinfoIsWholeMarker(authority.slice(0, at)))
|
|
329
|
-
pushEdit(edits, src,
|
|
342
|
+
pushEdit(edits, src, from, from + at, REDACTED_USERINFO);
|
|
330
343
|
const hash = tail.indexOf('#');
|
|
331
344
|
const beforeHash = hash === -1 ? tail : tail.slice(0, hash);
|
|
332
345
|
const question = beforeHash.indexOf('?');
|
|
333
346
|
const path = question === -1 ? beforeHash : beforeHash.slice(0, question);
|
|
334
|
-
pathCandidates(src,
|
|
347
|
+
pathCandidates(src, tailStart, path, opaqueSegments, edits, soft);
|
|
348
|
+
if (whole) {
|
|
349
|
+
const cut = pathCutAfterFirstLabel(path, true);
|
|
350
|
+
if (cut !== -1 && fragmentTerminatorFrom(path, cut))
|
|
351
|
+
pushEdit(edits, src, tailStart + cut, tailStart + path.length, REDACTED_SECRET);
|
|
352
|
+
}
|
|
335
353
|
if (question !== -1)
|
|
336
|
-
queryCandidates(src,
|
|
354
|
+
queryCandidates(src, tailStart + question + 1, beforeHash.slice(question + 1), edits, soft, byShape);
|
|
337
355
|
if (hash !== -1) {
|
|
338
356
|
const rawFragment = tail.slice(hash + 1);
|
|
339
|
-
const
|
|
340
|
-
if (rawFragment.length > 0 && !slotIsWholeMarker(rawFragment, soft && ((i) => soft(
|
|
341
|
-
pushEdit(edits, src,
|
|
357
|
+
const fragAt = tailStart + hash + 1;
|
|
358
|
+
if (rawFragment.length > 0 && !slotIsWholeMarker(rawFragment, soft && ((i) => soft(fragAt + i))))
|
|
359
|
+
pushEdit(edits, src, fragAt, end, REDACTED_FRAGMENT);
|
|
342
360
|
}
|
|
361
|
+
if (question !== -1)
|
|
362
|
+
regions.push([tailStart + question + 1, tailStart + beforeHash.length, 'query']);
|
|
363
|
+
if (hash !== -1 && hash + 1 < tail.length)
|
|
364
|
+
regions.push([tailStart + hash + 1, end, 'fragment']);
|
|
365
|
+
if (hostRegion && authority.length > 0) {
|
|
366
|
+
const hostFrom = at === -1 ? from : from + at + 1;
|
|
367
|
+
if (authorityIsHostPort(src, hostFrom, tailStart))
|
|
368
|
+
regions.push([hostFrom, tailStart, 'host']);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
function relativeAddressCandidates(text, out, regions, unitPos, soft, hostRegion = true) {
|
|
372
|
+
let p0 = 0;
|
|
373
|
+
while (p0 < text.length && (isWhitespaceOrControl(text.charAt(p0)) || text.charAt(p0) === VIEW_SEPARATOR))
|
|
374
|
+
p0++;
|
|
375
|
+
const c0 = text.charAt(p0);
|
|
376
|
+
if (c0 !== '/' && c0 !== '?' && c0 !== '#')
|
|
377
|
+
return false;
|
|
378
|
+
let end = text.length;
|
|
379
|
+
while (end > p0 && (text.charAt(end - 1) === VIEW_SEPARATOR || isWhitespaceOrControl(text.charAt(end - 1)) || isUnicodeBlank(text.charCodeAt(end - 1))))
|
|
380
|
+
end--;
|
|
381
|
+
end = trailingCloserEnd(text, p0, p0 + 1, end, unitPos);
|
|
382
|
+
const from = text.startsWith('//', p0) ? p0 + 2 : p0;
|
|
383
|
+
const tokenEdits = [];
|
|
384
|
+
addressCandidates(text, from, end, true, tokenEdits, regions, soft, false, true, hostRegion);
|
|
385
|
+
editsToCandidates(tokenEdits, 'url', out, end);
|
|
386
|
+
return true;
|
|
343
387
|
}
|
|
344
|
-
function urlCandidates(text, out, regions, unitPos = () => false, soft, byShape = false) {
|
|
388
|
+
function urlCandidates(text, out, regions, unitPos = () => false, soft, byShape = false, whole = false, hostRegion = whole) {
|
|
389
|
+
if (whole && relativeAddressCandidates(text, out, regions, unitPos, soft, hostRegion))
|
|
390
|
+
return;
|
|
345
391
|
let mark = text.indexOf('://');
|
|
346
392
|
while (mark !== -1) {
|
|
347
393
|
let start = mark;
|
|
@@ -366,7 +412,9 @@ function urlCandidates(text, out, regions, unitPos = () => false, soft, byShape
|
|
|
366
412
|
}
|
|
367
413
|
return at <= firstVisible;
|
|
368
414
|
};
|
|
369
|
-
|
|
415
|
+
if (whole)
|
|
416
|
+
end = text.length;
|
|
417
|
+
while (!whole && end < text.length) {
|
|
370
418
|
const ch = text.charAt(end);
|
|
371
419
|
if (isWhitespaceOrControl(ch))
|
|
372
420
|
break;
|
|
@@ -397,7 +445,7 @@ function urlCandidates(text, out, regions, unitPos = () => false, soft, byShape
|
|
|
397
445
|
seenPathSep = true;
|
|
398
446
|
end++;
|
|
399
447
|
}
|
|
400
|
-
while (end > mark + 3 && text.charAt(end - 1) === VIEW_SEPARATOR)
|
|
448
|
+
while (end > mark + 3 && (text.charAt(end - 1) === VIEW_SEPARATOR || (whole && (isWhitespaceOrControl(text.charAt(end - 1)) || isUnicodeBlank(text.charCodeAt(end - 1))))))
|
|
401
449
|
end--;
|
|
402
450
|
let runStart = end;
|
|
403
451
|
while (runStart > mark + 3 && TRAILING_PUNCTUATION.has(text.charAt(runStart - 1)))
|
|
@@ -406,21 +454,8 @@ function urlCandidates(text, out, regions, unitPos = () => false, soft, byShape
|
|
|
406
454
|
end = runStart;
|
|
407
455
|
end = trailingCloserEnd(text, start, mark + 3, end, unitPos);
|
|
408
456
|
const tokenEdits = [];
|
|
409
|
-
|
|
457
|
+
addressCandidates(text, mark + 3, end, !/^file:/i.test(text.slice(start, mark + 3)), tokenEdits, regions, soft, byShape, whole, hostRegion);
|
|
410
458
|
editsToCandidates(tokenEdits, 'url', out, end);
|
|
411
|
-
const token = text.slice(start, end);
|
|
412
|
-
const schemeEnd = token.indexOf('://') + 3;
|
|
413
|
-
const rest = token.slice(schemeEnd);
|
|
414
|
-
const authorityEnd = rest.search(/[/?#]/);
|
|
415
|
-
const tailStart = schemeEnd + (authorityEnd === -1 ? rest.length : authorityEnd);
|
|
416
|
-
const tail = token.slice(tailStart);
|
|
417
|
-
const hash = tail.indexOf('#');
|
|
418
|
-
const beforeHash = hash === -1 ? tail : tail.slice(0, hash);
|
|
419
|
-
const question = beforeHash.indexOf('?');
|
|
420
|
-
if (question !== -1)
|
|
421
|
-
regions.push([start + tailStart + question + 1, start + tailStart + beforeHash.length, 'query']);
|
|
422
|
-
if (hash !== -1 && hash + 1 < tail.length)
|
|
423
|
-
regions.push([start + tailStart + hash + 1, end, 'fragment']);
|
|
424
459
|
mark = text.indexOf('://', end > mark + 3 ? end : mark + 3);
|
|
425
460
|
}
|
|
426
461
|
}
|
|
@@ -914,7 +949,7 @@ function codeSpanClose(text, plain) {
|
|
|
914
949
|
}
|
|
915
950
|
return close;
|
|
916
951
|
}
|
|
917
|
-
const BRACKET_PAIRS = new Map([['(', ')'], ['[', ']']]);
|
|
952
|
+
const BRACKET_PAIRS = new Map([['(', ')'], ['[', ']'], ['{', '}'], ['<', '>']]);
|
|
918
953
|
class InnerWordIndex {
|
|
919
954
|
text;
|
|
920
955
|
tokenInner;
|
|
@@ -960,22 +995,34 @@ class InnerWordIndex {
|
|
|
960
995
|
}
|
|
961
996
|
}
|
|
962
997
|
const WRAPPED_PLACEHOLDER = /^(?:[A-Z]{1,12}(?:_[A-Z]{1,12})*|[a-z]{1,12}(?:-[a-z]{1,12})*)$/;
|
|
998
|
+
const TEMPLATE_PLACEHOLDER = /^[a-z]{1,12}(?:_[a-z]{1,12})+$/;
|
|
999
|
+
function isWrappedPlaceholder(inner, open) {
|
|
1000
|
+
return WRAPPED_PLACEHOLDER.test(inner) || ((open === '{' || open === '<') && TEMPLATE_PLACEHOLDER.test(inner));
|
|
1001
|
+
}
|
|
963
1002
|
function wrappedValueAt(text, from, idx) {
|
|
964
1003
|
let k = from;
|
|
965
1004
|
while (k < text.length && text[k] === VIEW_SEPARATOR)
|
|
966
1005
|
k++;
|
|
967
|
-
const
|
|
1006
|
+
const open = text.charAt(k);
|
|
1007
|
+
const close = BRACKET_PAIRS.get(open);
|
|
968
1008
|
if (close === undefined || credentialWordStartsAt(text, k + 1, idx.tokenInner))
|
|
969
1009
|
return null;
|
|
970
1010
|
const inner = scanSecretValue(text, k + 1, idx);
|
|
971
1011
|
if (inner === null || inner.start !== k + 1)
|
|
972
1012
|
return null;
|
|
973
|
-
let
|
|
1013
|
+
let innerEnd = inner.end;
|
|
1014
|
+
let semi = innerEnd;
|
|
1015
|
+
while (semi < text.length && text[semi] === VIEW_SEPARATOR)
|
|
1016
|
+
semi++;
|
|
1017
|
+
const cont = separatorContinuedEnd(text, semi, idx);
|
|
1018
|
+
if (cont !== -1)
|
|
1019
|
+
innerEnd = cont;
|
|
1020
|
+
let c = innerEnd;
|
|
974
1021
|
while (c < text.length && text[c] === VIEW_SEPARATOR)
|
|
975
1022
|
c++;
|
|
976
1023
|
if (text.charAt(c) !== close || (close === ']' && text.charAt(c + 1) === '('))
|
|
977
1024
|
return null;
|
|
978
|
-
return inner;
|
|
1025
|
+
return { start: inner.start, end: innerEnd, open };
|
|
979
1026
|
}
|
|
980
1027
|
function tokenSchemeValueEnd(text, start, end, idx) {
|
|
981
1028
|
if (withoutSeparators(text.slice(start, end)).toLowerCase() !== 'token')
|
|
@@ -1115,6 +1162,9 @@ function isDiagnosticWord(value) {
|
|
|
1115
1162
|
const bare = value.replace(/^\.+/, '').replace(/[.,;:!?)\]}'"]{0,8}$/, '').toLowerCase();
|
|
1116
1163
|
return bare === '' || DIAGNOSTIC_VALUE_WORDS.has(bare);
|
|
1117
1164
|
}
|
|
1165
|
+
export function isDiagnosticValueWord(value) {
|
|
1166
|
+
return typeof value === 'string' && isDiagnosticWord(value);
|
|
1167
|
+
}
|
|
1118
1168
|
const TOKEN_COUNT_HEAD_WORDS = new Set([
|
|
1119
1169
|
'max', 'min', 'num', 'n', 'input', 'output', 'total', 'prompt', 'completion', 'thinking', 'reasoning',
|
|
1120
1170
|
'cache', 'cached', 'context', 'budget', 'used', 'remaining', 'reserved', 'new', 'effective', 'limit',
|
|
@@ -1171,7 +1221,7 @@ function isNamedNotValue(label, value) {
|
|
|
1171
1221
|
return true;
|
|
1172
1222
|
return isBacktickedCredentialName(value);
|
|
1173
1223
|
}
|
|
1174
|
-
function schemeIsLabelValue(text, at) {
|
|
1224
|
+
function schemeIsLabelValue(text, at, outer = false) {
|
|
1175
1225
|
let k = at;
|
|
1176
1226
|
while (k > 0 && text[k - 1] === VIEW_SEPARATOR)
|
|
1177
1227
|
k--;
|
|
@@ -1180,7 +1230,7 @@ function schemeIsLabelValue(text, at) {
|
|
|
1180
1230
|
while (k > 0 && text.charCodeAt(k - 1) === 0x5c)
|
|
1181
1231
|
k--;
|
|
1182
1232
|
}
|
|
1183
|
-
return k > 0 && labelEndsAt(text, k);
|
|
1233
|
+
return k > 0 && labelEndsAt(text, k, false, outer);
|
|
1184
1234
|
}
|
|
1185
1235
|
function labelQuotedAt(text, at, sep) {
|
|
1186
1236
|
const q = text.charAt(at - 1);
|
|
@@ -1299,10 +1349,14 @@ function percentLayers(text) {
|
|
|
1299
1349
|
}
|
|
1300
1350
|
return out;
|
|
1301
1351
|
}
|
|
1302
|
-
function firstLabelCutInPath(path) {
|
|
1352
|
+
function firstLabelCutInPath(path, outer = false) {
|
|
1303
1353
|
let cut = -1;
|
|
1304
|
-
|
|
1305
|
-
|
|
1354
|
+
const sources = outer ? [[SCHEME_WORD_OUTER_SOURCE, false], [LABEL_WORD_OUTER_SOURCE, true]] : [[SECRET_SCHEME_WORD.source, false], [SECRET_LABELLED_WORD.source, false]];
|
|
1355
|
+
for (const [source, countExempt] of sources) {
|
|
1356
|
+
const re = new RegExp(source, 'gi');
|
|
1357
|
+
let hit = re.exec(path);
|
|
1358
|
+
while (hit !== null && countExempt && isTokenCountLabel(path, hit.index, hit[1] ?? ''))
|
|
1359
|
+
hit = re.exec(path);
|
|
1306
1360
|
if (hit === null)
|
|
1307
1361
|
continue;
|
|
1308
1362
|
const at = hit.index + hit[0].length;
|
|
@@ -1313,11 +1367,11 @@ function firstLabelCutInPath(path) {
|
|
|
1313
1367
|
}
|
|
1314
1368
|
return cut;
|
|
1315
1369
|
}
|
|
1316
|
-
function pathCutAfterFirstLabel(path) {
|
|
1317
|
-
let cut = firstLabelCutInPath(path);
|
|
1370
|
+
function pathCutAfterFirstLabel(path, outer = false) {
|
|
1371
|
+
let cut = firstLabelCutInPath(path, outer);
|
|
1318
1372
|
const { decoded, offsets } = percentDecodeForMatching(path);
|
|
1319
1373
|
if (decoded !== path) {
|
|
1320
|
-
const decodedCut = firstLabelCutInPath(decoded);
|
|
1374
|
+
const decodedCut = firstLabelCutInPath(decoded, outer);
|
|
1321
1375
|
if (decodedCut !== -1) {
|
|
1322
1376
|
const mapped = offsets[decodedCut] ?? path.length;
|
|
1323
1377
|
if (mapped < path.length && (cut === -1 || mapped < cut))
|
|
@@ -2130,6 +2184,62 @@ function blockSeqEntries(scan, rawFrom, rawLabel) {
|
|
|
2130
2184
|
}
|
|
2131
2185
|
return out;
|
|
2132
2186
|
}
|
|
2187
|
+
function separatorContinuedEnd(text, at, idx) {
|
|
2188
|
+
const isSep = (ch) => ch === ';';
|
|
2189
|
+
let end = -1;
|
|
2190
|
+
let p = at;
|
|
2191
|
+
for (;;) {
|
|
2192
|
+
if (!isSep(text.charAt(p)))
|
|
2193
|
+
return end;
|
|
2194
|
+
let k = p;
|
|
2195
|
+
while (k < text.length && (isSep(text.charAt(k)) || text[k] === VIEW_SEPARATOR))
|
|
2196
|
+
k++;
|
|
2197
|
+
if (k >= text.length || isBareValueStop(text.charAt(k)))
|
|
2198
|
+
return end;
|
|
2199
|
+
if (credentialWordStartsAt(text, k, idx.tokenInner) || PAIR_ITEM.test(text.slice(k, k + 256)))
|
|
2200
|
+
return end;
|
|
2201
|
+
const v = scanSecretValue(text, k, idx);
|
|
2202
|
+
if (v === null || v.end <= k)
|
|
2203
|
+
return end;
|
|
2204
|
+
end = v.end;
|
|
2205
|
+
p = v.end;
|
|
2206
|
+
while (p < text.length && text[p] === VIEW_SEPARATOR)
|
|
2207
|
+
p++;
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
const ENV_ASSIGNED_NAME = /^[A-Z][A-Z0-9_]*$/;
|
|
2211
|
+
const ENV_ASSIGNMENT_AHEAD = /^[A-Z_][A-Z0-9_]*=[^=\s]/;
|
|
2212
|
+
function envSchemeWordReading(text, at) {
|
|
2213
|
+
if (at < 2 || text.charCodeAt(at - 1) !== 0x3d)
|
|
2214
|
+
return null;
|
|
2215
|
+
let e = at;
|
|
2216
|
+
while (e < text.length && isAlpha(text.charAt(e)))
|
|
2217
|
+
e++;
|
|
2218
|
+
const word = text.slice(at, e).toLowerCase();
|
|
2219
|
+
if (word !== 'bearer' && word !== 'basic')
|
|
2220
|
+
return null;
|
|
2221
|
+
let w = at - 1;
|
|
2222
|
+
while (w > 0 && isKeyWordChar(text.charCodeAt(w - 1)) && text.charCodeAt(w - 1) !== 0x2d)
|
|
2223
|
+
w--;
|
|
2224
|
+
if (!ENV_ASSIGNED_NAME.test(text.slice(w, at - 1)) || !labelEndsAt(text, at, false, true))
|
|
2225
|
+
return null;
|
|
2226
|
+
const inline = (p) => {
|
|
2227
|
+
while (p < text.length && (text[p] === ' ' || text[p] === '\t' || text[p] === VIEW_SEPARATOR))
|
|
2228
|
+
p++;
|
|
2229
|
+
return p;
|
|
2230
|
+
};
|
|
2231
|
+
const k = inline(e);
|
|
2232
|
+
if (k >= text.length)
|
|
2233
|
+
return { end: e, beforeAssignment: false };
|
|
2234
|
+
const c = text.charCodeAt(k);
|
|
2235
|
+
if (c === 0x0a || c === 0x0d || c === 0x2028 || c === 0x2029) {
|
|
2236
|
+
let n = k + 1;
|
|
2237
|
+
if (c === 0x0d && text.charCodeAt(n) === 0x0a)
|
|
2238
|
+
n++;
|
|
2239
|
+
return { end: e, beforeAssignment: ENV_ASSIGNMENT_AHEAD.test(text.slice(inline(n), inline(n) + 256)) };
|
|
2240
|
+
}
|
|
2241
|
+
return k > e && ENV_ASSIGNMENT_AHEAD.test(text.slice(k, k + 256)) ? { end: e, beforeAssignment: true } : null;
|
|
2242
|
+
}
|
|
2133
2243
|
function labelCandidates(S, pass, regions, out, blocks, outer = false) {
|
|
2134
2244
|
const text = S.text;
|
|
2135
2245
|
const unitAt = (k) => S.unitAt(k);
|
|
@@ -2354,8 +2464,9 @@ function labelCandidates(S, pass, regions, out, blocks, outer = false) {
|
|
|
2354
2464
|
if (regionKind !== null)
|
|
2355
2465
|
for (const r of regions)
|
|
2356
2466
|
for (let k = r[0]; k < r[1] && k < text.length; k++)
|
|
2357
|
-
regionKind[k] = r[2] === 'query' ? 1 : 2;
|
|
2467
|
+
regionKind[k] = r[2] === 'query' ? 1 : r[2] === 'fragment' ? 2 : 3;
|
|
2358
2468
|
const inQuery = (k) => regionKind !== null && k < text.length && regionKind[k] === 1;
|
|
2469
|
+
const inHost = (k) => regionKind !== null && k < text.length && regionKind[k] === 3;
|
|
2359
2470
|
const forbiddenTailAt = (p) => {
|
|
2360
2471
|
if (!PASSWORD_FORBIDDEN.has(text.charAt(p)))
|
|
2361
2472
|
return -1;
|
|
@@ -2388,6 +2499,10 @@ function labelCandidates(S, pass, regions, out, blocks, outer = false) {
|
|
|
2388
2499
|
}
|
|
2389
2500
|
if (hit.index >= skipFrom && hit.index < skipTo)
|
|
2390
2501
|
continue;
|
|
2502
|
+
if (inHost(hit.index))
|
|
2503
|
+
continue;
|
|
2504
|
+
if (schemePass && envSchemeWordReading(text, hit.index)?.beforeAssignment === true)
|
|
2505
|
+
continue;
|
|
2391
2506
|
if (schemePass && (label.toLowerCase() === 'token') !== tokenPass)
|
|
2392
2507
|
continue;
|
|
2393
2508
|
if (isTokenCountLabel(text, hit.index, label))
|
|
@@ -2407,6 +2522,14 @@ function labelCandidates(S, pass, regions, out, blocks, outer = false) {
|
|
|
2407
2522
|
if (isQuoteChar(text.charAt(q)))
|
|
2408
2523
|
from = k;
|
|
2409
2524
|
}
|
|
2525
|
+
if (!schemePass) {
|
|
2526
|
+
const ev = envSchemeWordReading(text, from);
|
|
2527
|
+
if (ev !== null) {
|
|
2528
|
+
push(from, ev.end, REDACTED_SECRET);
|
|
2529
|
+
re.lastIndex = ev.end;
|
|
2530
|
+
continue;
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2410
2533
|
const colonSep = isColonSeparator(hit[0].slice((hit[1] ?? '').length));
|
|
2411
2534
|
let bulletSkipped = false;
|
|
2412
2535
|
for (;;) {
|
|
@@ -2473,12 +2596,25 @@ function labelCandidates(S, pass, regions, out, blocks, outer = false) {
|
|
|
2473
2596
|
if (v0s === null) {
|
|
2474
2597
|
const w = wrappedValueAt(text, from, idx);
|
|
2475
2598
|
if (w !== null) {
|
|
2476
|
-
if (
|
|
2599
|
+
if (isWrappedPlaceholder(withoutSeparators(text.slice(w.start, w.end)), w.open))
|
|
2477
2600
|
continue;
|
|
2478
2601
|
v0s = w;
|
|
2479
2602
|
wrapEnd = w.end;
|
|
2480
2603
|
}
|
|
2481
2604
|
}
|
|
2605
|
+
if (wrapEnd === -1) {
|
|
2606
|
+
let qq = from;
|
|
2607
|
+
while (text.charCodeAt(qq) === 0x5c)
|
|
2608
|
+
qq++;
|
|
2609
|
+
if (!isQuoteChar(text.charAt(qq))) {
|
|
2610
|
+
let sepAt = v0s === null ? from : v0s.end;
|
|
2611
|
+
while (sepAt < text.length && text[sepAt] === VIEW_SEPARATOR)
|
|
2612
|
+
sepAt++;
|
|
2613
|
+
const cont = separatorContinuedEnd(text, sepAt, idx);
|
|
2614
|
+
if (cont !== -1)
|
|
2615
|
+
v0s = { start: v0s === null ? sepAt : v0s.start, end: cont };
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2482
2618
|
if (v0s === null) {
|
|
2483
2619
|
let k = from;
|
|
2484
2620
|
while (k < text.length && text[k] === VIEW_SEPARATOR)
|
|
@@ -2602,7 +2738,8 @@ function labelCandidates(S, pass, regions, out, blocks, outer = false) {
|
|
|
2602
2738
|
re.lastIndex = quoted ? from : v.end;
|
|
2603
2739
|
continue;
|
|
2604
2740
|
}
|
|
2605
|
-
|
|
2741
|
+
const labelledScheme = schemePass && label.toLowerCase() !== 'token' && schemeIsLabelValue(text, hit.index, true);
|
|
2742
|
+
if (schemePass && !quoted && !labelledScheme && schemeFollowerReleased(label, value, text.charCodeAt(hit.index - 1) === 0x2f)) {
|
|
2606
2743
|
re.lastIndex = v.end;
|
|
2607
2744
|
continue;
|
|
2608
2745
|
}
|
|
@@ -3672,31 +3809,48 @@ function screenSurfaces(text, o) {
|
|
|
3672
3809
|
function percentSurfaces(raw, text, base, o) {
|
|
3673
3810
|
const surfaces = [];
|
|
3674
3811
|
const contents = [];
|
|
3675
|
-
for (const layer of percentLayers(text))
|
|
3676
|
-
|
|
3677
|
-
const ps = new Int32Array(n);
|
|
3678
|
-
const pe = new Int32Array(n);
|
|
3679
|
-
const pdot = new Uint8Array(n);
|
|
3680
|
-
for (let k = 0; k < n; k++) {
|
|
3681
|
-
const a = layer.ps[k] ?? 0;
|
|
3682
|
-
const b = layer.pe[k] ?? 0;
|
|
3683
|
-
ps[k] = base === null ? a : (base.ps[a] ?? 0);
|
|
3684
|
-
pe[k] = base === null ? b : (base.pe[b - 1] ?? 0);
|
|
3685
|
-
if (base !== null && b - a === 1)
|
|
3686
|
-
pdot[k] = base.pdot[a] ?? 0;
|
|
3687
|
-
}
|
|
3688
|
-
const M = { ps, pe, pdot, rawDot: base === null ? new Uint8Array(raw.length) : base.rawDot };
|
|
3689
|
-
const VD = buildScanView(layer.text, o);
|
|
3690
|
-
const sep = separatedSurface(raw, VD, M);
|
|
3691
|
-
surfaces.push(base === null ? { ...sep, rawDot: null } : sep);
|
|
3692
|
-
const joined = joinedSurface(raw, VD, false, M);
|
|
3693
|
-
if (joined !== null)
|
|
3694
|
-
surfaces.push(base === null ? { ...joined, rawDot: null } : joined);
|
|
3695
|
-
for (const [a, b] of VD.contents)
|
|
3696
|
-
contents.push({ sub: layer.text.slice(a, b), rawAt: (k) => ps[a + k] ?? 0, rawEndAt: (k) => pe[a + k] ?? 0 });
|
|
3697
|
-
}
|
|
3812
|
+
for (const layer of percentLayers(text))
|
|
3813
|
+
layerSurfaces(raw, layer, base, o, surfaces, contents);
|
|
3698
3814
|
return { surfaces, contents };
|
|
3699
3815
|
}
|
|
3816
|
+
function layerSurfaces(raw, layer, base, o, surfaces, contents, decoded = true) {
|
|
3817
|
+
const n = layer.text.length;
|
|
3818
|
+
const ps = new Int32Array(n);
|
|
3819
|
+
const pe = new Int32Array(n);
|
|
3820
|
+
const pdot = new Uint8Array(n);
|
|
3821
|
+
for (let k = 0; k < n; k++) {
|
|
3822
|
+
const a = layer.ps[k] ?? 0;
|
|
3823
|
+
const b = layer.pe[k] ?? 0;
|
|
3824
|
+
ps[k] = base === null ? a : (base.ps[a] ?? 0);
|
|
3825
|
+
pe[k] = base === null ? b : (base.pe[b - 1] ?? 0);
|
|
3826
|
+
if (base !== null && b - a === 1)
|
|
3827
|
+
pdot[k] = base.pdot[a] ?? 0;
|
|
3828
|
+
}
|
|
3829
|
+
const M = { ps, pe, pdot, rawDot: base === null ? new Uint8Array(raw.length) : base.rawDot };
|
|
3830
|
+
const VD = buildScanView(layer.text, o);
|
|
3831
|
+
const sep = separatedSurface(raw, VD, M);
|
|
3832
|
+
surfaces.push(base === null ? { ...sep, rawDot: null, decoded } : { ...sep, decoded });
|
|
3833
|
+
const joined = joinedSurface(raw, VD, false, M);
|
|
3834
|
+
if (joined !== null)
|
|
3835
|
+
surfaces.push(base === null ? { ...joined, rawDot: null, decoded } : { ...joined, decoded });
|
|
3836
|
+
for (const [a, b] of VD.contents)
|
|
3837
|
+
contents.push({ sub: layer.text.slice(a, b), rawAt: (k) => ps[a + k] ?? 0, rawEndAt: (k) => pe[a + k] ?? 0 });
|
|
3838
|
+
}
|
|
3839
|
+
function parserViewLayer(text) {
|
|
3840
|
+
if (!/[\t\n\r]/.test(text))
|
|
3841
|
+
return null;
|
|
3842
|
+
const chars = [];
|
|
3843
|
+
const ps = [];
|
|
3844
|
+
for (let k = 0; k < text.length; k++) {
|
|
3845
|
+
const c = text.charCodeAt(k);
|
|
3846
|
+
if (c === 0x09 || c === 0x0a || c === 0x0d)
|
|
3847
|
+
continue;
|
|
3848
|
+
chars.push(text.charAt(k));
|
|
3849
|
+
ps.push(k);
|
|
3850
|
+
}
|
|
3851
|
+
const starts = Int32Array.from(ps);
|
|
3852
|
+
return { text: chars.join(''), ps: starts, pe: Int32Array.from(ps, (k) => k + 1) };
|
|
3853
|
+
}
|
|
3700
3854
|
function finalIsStructural(text, at) {
|
|
3701
3855
|
if (text.charCodeAt(at) !== 0x5c)
|
|
3702
3856
|
return false;
|
|
@@ -3968,6 +4122,11 @@ function collectCandidates(text, o, nested) {
|
|
|
3968
4122
|
const decoded = percentSurfaces(text, text, null, o);
|
|
3969
4123
|
surfaces.push(...decoded.surfaces);
|
|
3970
4124
|
const decodedContents = decoded.contents;
|
|
4125
|
+
if (o.wholeAddress === true) {
|
|
4126
|
+
const pv = parserViewLayer(text);
|
|
4127
|
+
if (pv !== null)
|
|
4128
|
+
layerSurfaces(text, pv, null, o, surfaces, decodedContents, false);
|
|
4129
|
+
}
|
|
3971
4130
|
const raw = [];
|
|
3972
4131
|
const blocks = { raw: text, view: V, out: raw, lines: [null, null], marks: null };
|
|
3973
4132
|
const regionSurface = screen.surfaces[0] ?? separated;
|
|
@@ -3977,7 +4136,7 @@ function collectCandidates(text, o, nested) {
|
|
|
3977
4136
|
const regions = [];
|
|
3978
4137
|
if (o.urls) {
|
|
3979
4138
|
const unitPos = (k) => S.dropped(k) || V.rawUnit[S.rawStart(k)] === 1;
|
|
3980
|
-
urlCandidates(S.text, cands, regions, unitPos, (k) => unitPos(k) || S.painted(k), o.queryByShape ?? false);
|
|
4139
|
+
urlCandidates(S.text, cands, regions, unitPos, (k) => unitPos(k) || S.painted(k), o.queryByShape ?? false, o.wholeAddress === true, o.wholeAddress === true && S.decoded !== true);
|
|
3981
4140
|
userinfoCandidates(S, cands, o.words);
|
|
3982
4141
|
}
|
|
3983
4142
|
if (o.words) {
|
|
@@ -4450,10 +4609,11 @@ function escapeSpacesFor(o, face) {
|
|
|
4450
4609
|
}
|
|
4451
4610
|
return set.size === 0 ? null : set;
|
|
4452
4611
|
}
|
|
4453
|
-
function scanOptionsOf(o, face, queryByShape = false) {
|
|
4612
|
+
function scanOptionsOf(o, face, queryByShape = false, wholeAddress = false) {
|
|
4454
4613
|
return {
|
|
4455
4614
|
urls: o.credentialUrls !== false,
|
|
4456
4615
|
queryByShape,
|
|
4616
|
+
wholeAddress,
|
|
4457
4617
|
words: o.credentialWords !== false,
|
|
4458
4618
|
blanks: face.keepBlanks === true,
|
|
4459
4619
|
fold: face.fold,
|
|
@@ -4468,11 +4628,11 @@ export function credentialWashPasses(text, opts = {}) {
|
|
|
4468
4628
|
scanAndMask(input, scan, false, stats);
|
|
4469
4629
|
return { passes: stats.passes, capped: stats.capped };
|
|
4470
4630
|
}
|
|
4471
|
-
function renderUntrusted(text, opts, ledger, queryByShape = false) {
|
|
4631
|
+
function renderUntrusted(text, opts, ledger, queryByShape = false, wholeAddress = false) {
|
|
4472
4632
|
const input = typeof text === 'string' ? text : String(text ?? '');
|
|
4473
4633
|
const o = opts ?? {};
|
|
4474
4634
|
const face = publicFace(o);
|
|
4475
|
-
const scan = scanOptionsOf(o, face, queryByShape);
|
|
4635
|
+
const scan = scanOptionsOf(o, face, queryByShape, wholeAddress);
|
|
4476
4636
|
const pairBackslashes = o.escapeBackslashes === true && face.mark !== 'dot' && face.mark !== 'space';
|
|
4477
4637
|
const book = ledger ?? (pairBackslashes ? { cps: [], lens: [] } : null);
|
|
4478
4638
|
if (book === null) {
|
|
@@ -4503,6 +4663,9 @@ export function displayUntrusted(text, opts = {}) {
|
|
|
4503
4663
|
const out = renderUntrusted(text, opts, null);
|
|
4504
4664
|
return typeof out === 'string' ? out : out.text;
|
|
4505
4665
|
}
|
|
4666
|
+
export function cleanUntrustedScalar(v) {
|
|
4667
|
+
return displayUntrusted(String(v ?? ''), { credentialUrls: false, credentialWords: false, foldLines: false });
|
|
4668
|
+
}
|
|
4506
4669
|
const NON_SECRET_FIELD_NAMES = new Set([
|
|
4507
4670
|
'deployment', 'deploymentname', 'deploymentid', 'name', 'tenant', 'tenantname', 'tenantid', 'region', 'location', 'zone',
|
|
4508
4671
|
'project', 'projectname', 'projectid', 'workspace', 'workspacename', 'workspaceid', 'resource', 'resourcename', 'resourcegroup',
|
|
@@ -4661,10 +4824,23 @@ function queryPartCarriesCredential(key, value, relax) {
|
|
|
4661
4824
|
if (relax && isNonSecretFieldName(key) && isReadableWordChain(value))
|
|
4662
4825
|
return isKnownSecretSegment(value);
|
|
4663
4826
|
}
|
|
4664
|
-
|
|
4827
|
+
if (isOpaqueSecretValue(value) || carriesCredentialStructure(value))
|
|
4828
|
+
return true;
|
|
4829
|
+
let from = 0;
|
|
4830
|
+
for (let i = 0; i <= value.length; i++) {
|
|
4831
|
+
if (i < value.length && !endsUrlFragmentAt(value, i))
|
|
4832
|
+
continue;
|
|
4833
|
+
if (i > from && (from > 0 || i < value.length)) {
|
|
4834
|
+
const chunk = value.slice(from, i);
|
|
4835
|
+
if (isOpaqueSecretValue(chunk) || carriesCredentialStructure(chunk))
|
|
4836
|
+
return true;
|
|
4837
|
+
}
|
|
4838
|
+
from = i + 1;
|
|
4839
|
+
}
|
|
4840
|
+
return false;
|
|
4665
4841
|
}
|
|
4666
4842
|
const UPLOAD_PROBE_PREFIX = 'https://q.invalid/?';
|
|
4667
|
-
const UPLOAD_SCAN_OPTIONS = Object.freeze({ urls: true, queryByShape: 'strict', words: true, blanks: false, fold: false, face: null, escapeSpaces: null });
|
|
4843
|
+
const UPLOAD_SCAN_OPTIONS = Object.freeze({ urls: true, queryByShape: 'strict', wholeAddress: true, words: true, blanks: false, fold: false, face: null, escapeSpaces: null });
|
|
4668
4844
|
export function queryCarriesCredential(query) {
|
|
4669
4845
|
if (typeof query !== 'string' || query.length === 0)
|
|
4670
4846
|
return false;
|
|
@@ -4672,11 +4848,12 @@ export function queryCarriesCredential(query) {
|
|
|
4672
4848
|
return scanOnce(probe, UPLOAD_SCAN_OPTIONS, false).text !== probe;
|
|
4673
4849
|
}
|
|
4674
4850
|
export function displayConfiguredUrl(url, opts = {}) {
|
|
4675
|
-
const out = renderUntrusted(typeof url === 'string' ? configuredUrlScannable(url) : url, opts, null, 'relaxed');
|
|
4851
|
+
const out = renderUntrusted(typeof url === 'string' ? configuredUrlScannable(url) : url, opts, null, 'relaxed', true);
|
|
4676
4852
|
return typeof out === 'string' ? out : out.text;
|
|
4677
4853
|
}
|
|
4678
4854
|
function configuredUrlScannable(url) {
|
|
4679
|
-
|
|
4855
|
+
const view = url.replace(/[\t\n\r]/g, '').replace(/^[\u0000-\u0020]+/, '');
|
|
4856
|
+
if (/^[A-Za-z][A-Za-z0-9+.-]*:\/\//.test(view) || !/^[A-Za-z][A-Za-z0-9+.-]*:/.test(view))
|
|
4680
4857
|
return url;
|
|
4681
4858
|
let u;
|
|
4682
4859
|
try {
|
|
@@ -56,7 +56,7 @@ export interface EngineAgentRegistryRowView {
|
|
|
56
56
|
readonly description?: string;
|
|
57
57
|
readonly createdAt?: number;
|
|
58
58
|
}
|
|
59
|
-
export type EngineAgentRegistryUnavailableWhy = 'no_list_face' | 'route_absent' | 'ownership_required' | 'read_failed';
|
|
59
|
+
export type EngineAgentRegistryUnavailableWhy = 'no_list_face' | 'capability_unknown' | 'route_absent' | 'ownership_required' | 'read_failed';
|
|
60
60
|
export type EngineAgentRegistryListing = {
|
|
61
61
|
readonly kind: 'rows';
|
|
62
62
|
readonly rows: readonly EngineAgentRegistryRowView[];
|
|
@@ -33,6 +33,10 @@ export type EngineAgentPanelEvent = {
|
|
|
33
33
|
parentToolCallId?: string;
|
|
34
34
|
wireTaskId?: string;
|
|
35
35
|
taskIdOrigin?: 'wire';
|
|
36
|
+
final?: {
|
|
37
|
+
totalTokens?: true;
|
|
38
|
+
toolUses?: true;
|
|
39
|
+
};
|
|
36
40
|
} | {
|
|
37
41
|
kind: 'end';
|
|
38
42
|
taskId: string;
|
|
@@ -42,6 +46,7 @@ export type EngineAgentPanelEvent = {
|
|
|
42
46
|
report?: string;
|
|
43
47
|
wireTaskId?: string;
|
|
44
48
|
taskIdOrigin?: 'fleet-row' | 'wire';
|
|
49
|
+
sessionId?: string;
|
|
45
50
|
} | {
|
|
46
51
|
kind: 'sweep';
|
|
47
52
|
};
|
|
@@ -49,12 +54,17 @@ export declare const PANEL_TOOLUSES_LANE_POLICY: Readonly<Record<'tick' | 'fleet
|
|
|
49
54
|
export declare function markEnginePanelTaskResident(taskId: string): void;
|
|
50
55
|
export declare function clearEnginePanelTaskResident(taskId: string): void;
|
|
51
56
|
export declare function isEnginePanelTaskResident(taskId: string): boolean;
|
|
52
|
-
export declare function resolveEnginePanelTaskId(wireTaskId: string
|
|
57
|
+
export declare function resolveEnginePanelTaskId(wireTaskId: string): EnginePanelTaskIdentity;
|
|
53
58
|
export declare function clearEnginePanelTaskResidentByWire(wireTaskId: string, cycle?: EngineAgentPanelCycleIdentity): void;
|
|
54
59
|
export declare function __resetEngineAgentPanelIdentityForTests(): void;
|
|
55
60
|
export declare function __resetEnginePanelStateForTests(): void;
|
|
56
61
|
export declare function publishEngineAgentPanelEvent(ev: EngineAgentPanelEvent): void;
|
|
57
|
-
export
|
|
62
|
+
export interface EngineAgentPanelStart {
|
|
63
|
+
taskId: string;
|
|
64
|
+
startedAt?: number;
|
|
65
|
+
workflowRunId?: string;
|
|
66
|
+
}
|
|
67
|
+
export declare function publishEngineAgentPanelStart(ev: EngineAgentPanelStart): void;
|
|
58
68
|
export declare function subscribeEnginePanelRows(fn: (delta: PanelDelta) => void): () => void;
|
|
59
69
|
export interface EngineAgentPanelAbsence {
|
|
60
70
|
taskId: string;
|
|
@@ -63,5 +73,3 @@ export interface EngineAgentPanelAbsence {
|
|
|
63
73
|
wireTaskId?: string;
|
|
64
74
|
}
|
|
65
75
|
export declare function publishEngineAgentPanelAbsence(ev: EngineAgentPanelAbsence): void;
|
|
66
|
-
export declare function subscribeEngineAgentPanelAbsence(fn: (ev: EngineAgentPanelAbsence) => void): () => void;
|
|
67
|
-
export declare function __resetEngineAgentPanelAbsenceForTests(): void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isNewEngineAgentPanelCycle, isStaleEngineAgentPanelEnd, panelIsResident, panelResolveTaskId, MAX_HELD_WIRE_TICK_BEATS, } from './panelReduce.js';
|
|
2
|
-
import {
|
|
2
|
+
import { guardedRead, readOwnDataFiniteNumber, readOwnDataNonEmptyString } from './ownKey.js';
|
|
3
|
+
import { clearEnginePanelIdentity, panelStateNow, stepEnginePanel, subscribeRows, resetEnginePanelHolder } from './panelStateHolder.js';
|
|
3
4
|
export { isNewEngineAgentPanelCycle, isStaleEngineAgentPanelEnd, MAX_HELD_WIRE_TICK_BEATS };
|
|
4
5
|
const _panelToolUsesLanePins = [true, true];
|
|
5
6
|
void _panelToolUsesLanePins;
|
|
@@ -16,8 +17,8 @@ export function clearEnginePanelTaskResident(taskId) {
|
|
|
16
17
|
export function isEnginePanelTaskResident(taskId) {
|
|
17
18
|
return panelIsResident(panelStateNow(), taskId);
|
|
18
19
|
}
|
|
19
|
-
export function resolveEnginePanelTaskId(wireTaskId
|
|
20
|
-
return panelResolveTaskId(panelStateNow(), wireTaskId
|
|
20
|
+
export function resolveEnginePanelTaskId(wireTaskId) {
|
|
21
|
+
return panelResolveTaskId(panelStateNow(), wireTaskId);
|
|
21
22
|
}
|
|
22
23
|
export function clearEnginePanelTaskResidentByWire(wireTaskId, cycle) {
|
|
23
24
|
stepEnginePanel({ kind: 'resident-clear-wire', taskId: wireTaskId, ...(cycle !== undefined ? { cycle } : {}) });
|
|
@@ -31,8 +32,18 @@ export function __resetEnginePanelStateForTests() {
|
|
|
31
32
|
export function publishEngineAgentPanelEvent(ev) {
|
|
32
33
|
stepEnginePanel(ev);
|
|
33
34
|
}
|
|
34
|
-
export function
|
|
35
|
-
|
|
35
|
+
export function publishEngineAgentPanelStart(ev) {
|
|
36
|
+
const taskId = guardedRead(() => readOwnDataNonEmptyString(ev, 'taskId'));
|
|
37
|
+
if (taskId === undefined)
|
|
38
|
+
return;
|
|
39
|
+
const startedAt = guardedRead(() => readOwnDataFiniteNumber(ev, 'startedAt'));
|
|
40
|
+
const workflowRunId = guardedRead(() => readOwnDataNonEmptyString(ev, 'workflowRunId'));
|
|
41
|
+
stepEnginePanel({
|
|
42
|
+
kind: 'start',
|
|
43
|
+
taskId,
|
|
44
|
+
...(startedAt !== undefined ? { startedAt } : {}),
|
|
45
|
+
...(workflowRunId !== undefined ? { workflowRunId } : {}),
|
|
46
|
+
});
|
|
36
47
|
}
|
|
37
48
|
export function subscribeEnginePanelRows(fn) {
|
|
38
49
|
return subscribeRows(fn);
|
|
@@ -40,9 +51,3 @@ export function subscribeEnginePanelRows(fn) {
|
|
|
40
51
|
export function publishEngineAgentPanelAbsence(ev) {
|
|
41
52
|
stepEnginePanel({ kind: 'absence', absence: ev });
|
|
42
53
|
}
|
|
43
|
-
export function subscribeEngineAgentPanelAbsence(fn) {
|
|
44
|
-
return subscribeAbsence(fn);
|
|
45
|
-
}
|
|
46
|
-
export function __resetEngineAgentPanelAbsenceForTests() {
|
|
47
|
-
resetAbsenceChannel();
|
|
48
|
-
}
|