snipara-companion 3.2.19 → 3.2.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.ts +1534 -1502
  2. package/dist/index.js +17430 -17161
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -2747,1640 +2747,1672 @@ interface CodingLedgerExportCommandOptions extends CodingLedgerBuildOptions {
2747
2747
  declare function buildCodingIntelligenceLedger(options?: CodingLedgerBuildOptions): CodingIntelligenceLedger;
2748
2748
  declare function codingLedgerExportCommand(options: CodingLedgerExportCommandOptions): Promise<void>;
2749
2749
 
2750
- declare const TEAM_SYNC_STATE_RELATIVE_PATH: string;
2751
- type TeamSyncAttention = "note" | "watch" | "review" | "proof";
2752
- type TeamSyncWorkStatus = "active" | "completed" | "archived";
2753
- interface TeamSyncRecordInput {
2754
- summary: string;
2755
- files?: string[];
2756
- branch?: string;
2757
- actor?: string;
2758
- next?: string;
2759
- attention?: string;
2760
- risk?: string;
2761
- now?: Date;
2762
- }
2763
- interface TeamSyncWorkRecord {
2764
- id: string;
2765
- type: "work";
2766
- summary: string;
2767
- files: string[];
2768
- branch?: string;
2769
- actor?: string;
2770
- status: TeamSyncWorkStatus;
2771
- createdAt: string;
2772
- updatedAt: string;
2773
- completedAt?: string;
2774
- completionReason?: string;
2775
- archivedAt?: string;
2776
- archiveReason?: string;
2777
- }
2778
- interface TeamSyncHandoffRecord {
2779
- id: string;
2780
- type: "handoff";
2781
- summary: string;
2782
- files: string[];
2783
- next?: string;
2784
- attention?: TeamSyncAttention;
2785
- actor?: string;
2786
- createdAt: string;
2787
- }
2788
- interface TeamSyncState {
2789
- schemaVersion: "snipara.team-sync.v1";
2790
- updatedAt: string;
2791
- work: TeamSyncWorkRecord[];
2792
- handoffs: TeamSyncHandoffRecord[];
2793
- }
2794
- interface TeamSyncSummary {
2795
- activeWorkCount: number;
2796
- staleWorkCount: number;
2797
- completedWorkCount: number;
2798
- archivedWorkCount: number;
2799
- handoffCount: number;
2800
- files: string[];
2801
- staleWorkExplanation: TeamSyncStaleWorkExplanation;
2802
- hygieneActions: TeamSyncHygieneAction[];
2803
- latestActiveWork?: TeamSyncWorkRecord;
2804
- latestStaleWork?: TeamSyncWorkRecord;
2805
- latestCompletedWork?: TeamSyncWorkRecord;
2806
- latestArchivedWork?: TeamSyncWorkRecord;
2807
- latestHandoff?: TeamSyncHandoffRecord;
2808
- }
2809
- interface TeamSyncStaleWorkExplanation {
2810
- staleAfterHours: number;
2811
- autoArchiveAfterDays: number;
2812
- activeStaleCount: number;
2813
- autoArchivableCount: number;
2814
- completedIgnoredCount: number;
2815
- archivedIgnoredCount: number;
2816
- latestStaleWorkAgeHours?: number;
2817
- message: string;
2818
- }
2819
- interface TeamSyncHygieneAction {
2820
- kind: "sweep-preview" | "sweep-archive" | "complete-work" | "handoff";
2821
- command: string;
2750
+ declare const COLLABORATION_STATE_RELATIVE_PATH: string;
2751
+ type CollaborationGuardActionKind = "safe_to_ack" | "needs_handoff" | "needs_test" | "needs_package_review" | "blocking_conflict" | "guard_unavailable";
2752
+ interface CollaborationGuardActionCard {
2753
+ kind: CollaborationGuardActionKind;
2754
+ title: string;
2822
2755
  reason: string;
2823
- mutates: boolean;
2824
- }
2825
- interface TeamSyncCommandOptions {
2826
- id?: string;
2827
- summary?: string;
2828
- files?: string[];
2829
- branch?: string;
2830
- actor?: string;
2831
- next?: string;
2832
- attention?: string;
2833
- risk?: string;
2834
- adapterPack?: boolean;
2835
- adapterTarget?: string;
2836
- context?: string[];
2837
- proof?: string[];
2838
- acceptance?: string[];
2839
- conflictPosture?: string;
2840
- since?: string;
2841
- dir?: string;
2842
- includeSessionContext?: boolean;
2843
- emitOrchestratorHandoff?: boolean;
2844
- autoRouteOrchestrator?: boolean;
2845
- orchestratorPolicySource?: string;
2846
- output?: string;
2847
- days?: string;
2848
- dryRun?: boolean;
2849
- json?: boolean;
2756
+ severity: "info" | "watch" | "warning" | "critical";
2757
+ safeToAck: boolean;
2758
+ command?: string;
2759
+ conflictCode?: string;
2760
+ resource?: string;
2850
2761
  }
2851
- interface HostedAttempt<T> {
2762
+ interface HostedAttempt$1<T> {
2852
2763
  status: "skipped" | "ok" | "error";
2853
2764
  data?: T;
2854
2765
  error?: string;
2855
2766
  }
2856
- interface TeamSyncSweepResult {
2857
- action: "sweep";
2767
+ interface WorkflowCollaborationReceipt {
2768
+ workSessionId?: string;
2769
+ hostedSessionStatus: HostedAttempt$1<CollaborationSessionResponse>["status"];
2770
+ hostedClaimStatus?: HostedAttempt$1<CollaborationLeaseResponse>["status"];
2771
+ hostedReleaseStatus?: HostedAttempt$1<Array<{
2772
+ lease: CollaborationLeaseSummary;
2773
+ }>>["status"];
2774
+ hostedError?: string;
2775
+ files: string[];
2776
+ resourceCount: number;
2777
+ leaseCount: number;
2858
2778
  statePath: string;
2859
- dryRun: boolean;
2860
- thresholdDays: number;
2861
- thresholdMs: number;
2862
- archivedCount: number;
2863
- archivedWork: TeamSyncWorkRecord[];
2864
- explanation: TeamSyncSweepExplanation;
2865
- summary: TeamSyncSummary;
2866
- }
2867
- interface TeamSyncSweepExplanation {
2868
- mode: "preview" | "archive";
2869
- candidateCount: number;
2870
- archivedCount: number;
2871
- remainingStaleCount: number;
2872
- message: string;
2873
- }
2874
- type AgenticHandoffAdapterTarget = "codex" | "claude-code" | "cursor" | "orca" | "windsurf" | "custom";
2875
- type AgenticHandoffConflictPosture = "continue" | "wait" | "split_work" | "review_only" | "handoff";
2876
- interface AgenticHandoffAdapterPack {
2877
- version: "snipara.ade_adapter_pack.v1";
2878
- target: {
2879
- id: AgenticHandoffAdapterTarget;
2880
- label: string;
2881
- profile: string;
2882
- instruction: string;
2883
- runtimeControl: "handoff_only";
2884
- };
2885
- contextPack: {
2886
- summary: string;
2887
- files: string[];
2888
- contextRefs: string[];
2889
- workflow?: {
2890
- goal?: string;
2891
- status?: string;
2892
- currentPhaseId?: string;
2893
- currentPhaseTitle?: string;
2894
- };
2895
- resumeCommands: string[];
2896
- constraints: string[];
2897
- };
2898
- conflictPosture: AgenticHandoffConflictPosture;
2899
- proofGates: string[];
2900
- acceptanceCriteria: string[];
2901
- receiptExpectation: {
2902
- required: boolean;
2903
- command: string;
2904
- requiredFields: string[];
2905
- };
2906
- prompt: string;
2907
- caveats: string[];
2779
+ recordedAt: string;
2908
2780
  }
2909
- interface TeamSyncCompletionEvidenceOptions {
2781
+ interface CollaborationCommandOptions {
2910
2782
  summary?: string;
2911
- workflowGoal?: string;
2912
2783
  files?: string[];
2784
+ resources?: string[];
2785
+ actor?: string;
2786
+ actorId?: string;
2787
+ actorType?: string;
2788
+ sessionId?: string;
2789
+ workSessionId?: string;
2790
+ swarmId?: string;
2791
+ client?: string;
2792
+ repository?: string;
2793
+ branch?: string;
2794
+ worktree?: string;
2795
+ action?: string;
2796
+ profile?: string;
2797
+ mode?: string;
2913
2798
  reason?: string;
2914
- now?: Date;
2799
+ ttlSeconds?: string;
2800
+ heartbeatTtlSeconds?: string;
2801
+ intervalSeconds?: string;
2802
+ maxFiles?: string;
2803
+ leaseId?: string;
2804
+ all?: boolean;
2805
+ once?: boolean;
2806
+ autoClaim?: boolean;
2807
+ releaseStale?: boolean;
2808
+ persist?: boolean;
2809
+ enforce?: boolean;
2810
+ ackReviewOnly?: boolean;
2811
+ dir?: string;
2812
+ json?: boolean;
2813
+ verbose?: boolean;
2814
+ }
2815
+ interface CollaborationHooksInstallOptions {
2816
+ dir?: string;
2915
2817
  dryRun?: boolean;
2818
+ json?: boolean;
2916
2819
  }
2917
- interface AgenticHandoffArtifact {
2918
- version: "snipara.agentic_handoff.v1";
2919
- generatedAt: string;
2920
- command: "snipara-companion handoff";
2921
- record: TeamSyncHandoffRecord;
2922
- statePath: string;
2923
- hosted: {
2924
- status: HostedAttempt<TeamSyncHandoffResponse>["status"];
2925
- handoffId?: string;
2926
- error?: string;
2927
- };
2928
- sections: {
2929
- whatChanged: string[];
2930
- verified: string[];
2931
- risky: string[];
2932
- remains: string[];
2933
- whereToResume: string[];
2820
+ interface CollaborationLocalLeaseRecord {
2821
+ id: string;
2822
+ mode: CollaborationLeaseMode;
2823
+ status: CollaborationLeaseStatus;
2824
+ resources: CollaborationResource[];
2825
+ reason?: string;
2826
+ claimedAt?: string;
2827
+ expiresAt?: string | null;
2828
+ workSessionId?: string;
2829
+ }
2830
+ interface CollaborationLocalState {
2831
+ schemaVersion: "snipara.collaboration.v1";
2832
+ updatedAt: string;
2833
+ workSessionId?: string;
2834
+ sessionId?: string;
2835
+ actorId?: string;
2836
+ actorType?: CollaborationActorType;
2837
+ actorLabel?: string;
2838
+ client?: string;
2839
+ repository?: string;
2840
+ branch?: string;
2841
+ worktree?: string;
2842
+ task?: string;
2843
+ files: string[];
2844
+ resources: CollaborationResource[];
2845
+ leases: CollaborationLocalLeaseRecord[];
2846
+ lastGuard?: {
2847
+ decision: CollaborationGuardDecision;
2848
+ severity: string;
2849
+ checkedAt: string;
2850
+ action: string;
2851
+ resources: CollaborationResource[];
2852
+ conflictCount: number;
2934
2853
  };
2935
- suggestedCommands: string[];
2936
- adapter?: AgenticHandoffAdapterPack;
2937
2854
  }
2938
- declare function buildTeamSyncStartWorkRecord(input: TeamSyncRecordInput): TeamSyncWorkRecord;
2939
- declare function buildTeamSyncHandoffRecord(input: TeamSyncRecordInput): TeamSyncHandoffRecord;
2940
- declare function createEmptyTeamSyncState(now?: Date): TeamSyncState;
2941
- declare function buildTeamSyncSummary(state: TeamSyncState, since?: Date, now?: Date): TeamSyncSummary;
2942
- declare function archiveInactiveTeamSyncWork(state: TeamSyncState, options?: {
2943
- now?: Date;
2944
- thresholdMs?: number;
2945
- dryRun?: boolean;
2946
- }): TeamSyncSweepResult["archivedWork"];
2947
- declare function completeTeamSyncWorkFromEvidence(state: TeamSyncState, options?: TeamSyncCompletionEvidenceOptions): TeamSyncWorkRecord[];
2948
- declare function completeTeamSyncStateFromEvidence(rootDir?: string, options?: TeamSyncCompletionEvidenceOptions): TeamSyncWorkRecord[];
2949
- declare function autoArchiveTeamSyncState(rootDir?: string, now?: Date): TeamSyncSweepResult["archivedWork"];
2950
- declare function loadTeamSyncState(rootDir?: string): TeamSyncState;
2951
- declare function saveTeamSyncState(state: TeamSyncState, rootDir?: string): void;
2952
- declare function getTeamSyncStatePath(rootDir?: string): string;
2953
- declare function buildAgenticHandoffMarkdown(artifact: AgenticHandoffArtifact): string;
2954
- declare function teamSyncSweepCommand(options: TeamSyncCommandOptions): Promise<void>;
2955
-
2956
- type SyncDocumentKind = "DOC" | "BINARY";
2957
- type WorkflowMode = "lite" | "standard" | "auto" | "full" | "orchestrate";
2958
- type OnboardFolderMode = "auto" | "business_context" | "code_project" | "mixed";
2959
- type DetectedOnboardFolderMode = "business_context" | "code_project" | "mixed" | "unknown";
2960
- type ManagedWorkflowStatus = "active" | "completed" | "blocked";
2961
- type ManagedWorkflowPhaseStatus = "pending" | "in_progress" | "completed" | "blocked" | "skipped";
2962
- type ReindexKind = "doc" | "code";
2963
- type ReindexMode = "incremental" | "full";
2964
- type ManagedWorkflowPlanSource = "file" | "inline";
2965
- type TaskCommitOutcome = "completed" | "partial" | "blocked" | "abandoned";
2966
- type ManagedWorkflowSchemaVersion = "snipara.workflow.v1" | "snipara.workflow.v2";
2967
- declare const WORKFLOW_STATE_RELATIVE_PATH: string;
2968
- declare const WORKFLOW_PLANS_RELATIVE_DIR: string;
2969
- declare const PRODUCER_LOOP_ARTIFACT_VERSION: "snipara.producer_loop_artifact.v0";
2970
- declare const PRODUCER_LOOP_REPORT_VERSION: "snipara.producer_loop_report.v0";
2971
- declare const PRODUCER_LOOP_RELATIVE_DIR: string;
2972
- type ProducerLoopProducerKind = "workflow_phase_commit" | "workflow_final_commit" | "pr_answer_pack_decision_capture";
2973
- type ProducerLoopSampleReviewStatus = "sample_unreviewed" | "sample_reviewed" | "sample_rejected";
2974
- interface ProducerLoopArtifactWriteResult {
2975
- status: "written" | "error";
2976
- schemaVersion: typeof PRODUCER_LOOP_ARTIFACT_VERSION;
2977
- artifactId?: string;
2978
- path?: string;
2979
- relativePath?: string;
2980
- artifactHash?: string;
2981
- ledgerHash?: string;
2982
- error?: string;
2983
- caveats: string[];
2855
+ interface ResolvedCollaborationContext {
2856
+ rootDir: string;
2857
+ config: RLMConfig;
2858
+ actor: Required<Pick<CollaborationActorPayload, "actorId" | "actorType" | "actorLabel">> & {
2859
+ sessionId?: string;
2860
+ };
2861
+ client: string;
2862
+ branch?: string;
2863
+ repository?: string;
2864
+ worktree?: string;
2984
2865
  }
2985
- interface ProducerLoopArtifactReportSummary {
2986
- artifactId: string;
2987
- generatedAt: string;
2988
- producerKind: ProducerLoopProducerKind;
2989
- workflowId?: string;
2990
- phaseId?: string;
2991
- phaseTitle?: string;
2992
- outcome?: TaskCommitOutcome;
2993
- summary?: string;
2994
- path: string;
2995
- relativePath: string;
2996
- artifactHash: string;
2997
- ledgerHash?: string;
2998
- reasonCodes: string[];
2866
+ declare function createEmptyCollaborationState(now?: Date): CollaborationLocalState;
2867
+ declare function getCollaborationStatePath(rootDir?: string): string;
2868
+ declare function loadCollaborationState(rootDir?: string): CollaborationLocalState;
2869
+ declare function saveCollaborationState(state: CollaborationLocalState, rootDir?: string): void;
2870
+ declare function buildCollaborationActor(options: Pick<CollaborationCommandOptions, "actor" | "actorId" | "actorType" | "sessionId" | "client">, config: RLMConfig): ResolvedCollaborationContext["actor"];
2871
+ declare function normalizeCollaborationFiles(files: string[] | undefined): string[];
2872
+ declare function parseCollaborationResources(values: string[] | undefined): CollaborationResource[];
2873
+ declare function deriveLocalCollaborationResourcesFromFiles(files: string[] | undefined, rootDir?: string, maxFiles?: number): CollaborationResource[];
2874
+ declare function buildCollaborationHooksInstallPlan(options?: CollaborationHooksInstallOptions): Record<string, unknown>;
2875
+ declare function collaborationIdeStatusCommand(options: CollaborationCommandOptions): Promise<void>;
2876
+ declare function buildCollaborationGuardActionCards(evaluation: CollaborationGuardEvaluation | undefined, context?: {
2877
+ profile?: string;
2878
+ enforced?: boolean;
2879
+ ackReviewOnly?: boolean;
2880
+ reviewOnlyAcknowledged?: boolean;
2881
+ }): CollaborationGuardActionCard[];
2882
+ interface HostedGuardPayload {
2999
2883
  files: string[];
3000
- calibrationStatus?: string;
3001
- reviewStatus: ProducerLoopSampleReviewStatus;
3002
- reviewOutcome?: string;
3003
- reviewedAt?: string;
3004
- reviewer?: string;
2884
+ resources: CollaborationResource[];
2885
+ fileCount: number;
2886
+ resourceCount: number;
2887
+ filesTruncated: boolean;
2888
+ resourcesTruncated: boolean;
3005
2889
  }
3006
- interface ProducerLoopReport {
3007
- version: typeof PRODUCER_LOOP_REPORT_VERSION;
3008
- generatedAt: string;
3009
- source: {
3010
- directory: string;
3011
- localOnly: true;
2890
+ declare function buildHostedGuardPayload(files: string[], resources: CollaborationResource[]): HostedGuardPayload;
2891
+ declare function compactHostedGuardResources(resources: CollaborationResource[]): CollaborationResource[];
2892
+
2893
+ type RuntimeEnvironment = Record<string, string | undefined>;
2894
+ type ProviderKeySource = "environment" | "env-file";
2895
+ type OrchestratorRecommendationLevel = "suggest" | "confirm" | "auto";
2896
+ type OrchestratorRecommendationReason = "workflow_mode_orchestrate" | "production_validation_intent" | "proof_gate_intent" | "htask_or_swarm_intent" | "multi_agent_intent" | "parallel_worker_intent" | "changed_files_threshold" | "team_sync_collision" | "policy_auto_route";
2897
+ interface OrchestratorRecommendation {
2898
+ level: OrchestratorRecommendationLevel;
2899
+ reasons: OrchestratorRecommendationReason[];
2900
+ score: number;
2901
+ orchestratorRequired: boolean;
2902
+ policySource?: string;
2903
+ }
2904
+ interface OrchestratorRecommendationOptions {
2905
+ changedFilesCount?: number;
2906
+ hasActiveCollisions?: boolean;
2907
+ policyAutoRoute?: boolean;
2908
+ policySource?: string;
2909
+ adaptiveRoutingDryRun?: boolean;
2910
+ }
2911
+ interface RuntimeDetectionReport {
2912
+ cwd: string;
2913
+ workspaceRoot: string | null;
2914
+ companion: {
2915
+ configured: boolean;
2916
+ configPath: string;
3012
2917
  };
3013
- adoption: {
3014
- status: "missing" | "active";
3015
- artifactCount: number;
3016
- producerKinds: ProducerLoopProducerKind[];
3017
- workflowIds: string[];
2918
+ runtime: {
2919
+ cliAvailable: boolean;
2920
+ command?: string;
2921
+ legacyCommand?: boolean;
2922
+ version?: string;
2923
+ cliVersion?: string;
2924
+ installedPackageVersion?: string;
2925
+ versionMismatch?: boolean;
2926
+ mcpConfigured: boolean;
2927
+ mcpConfigPaths: string[];
3018
2928
  };
3019
- artifacts: ProducerLoopArtifactReportSummary[];
3020
- latestArtifact?: ProducerLoopArtifactReportSummary;
3021
- invalidArtifacts: Array<{
3022
- path: string;
3023
- relativePath: string;
3024
- error: string;
3025
- }>;
3026
- reasonCodes: {
3027
- counts: Record<string, number>;
2929
+ orchestrator: {
2930
+ cliAvailable: boolean;
2931
+ command?: string;
2932
+ version?: string;
2933
+ source?: "path" | "workspace_venv";
2934
+ workspacePackageVersion?: string;
2935
+ versionMismatch?: boolean;
3028
2936
  };
3029
- calibration: {
3030
- status: "no_samples" | "insufficient_samples" | "reviewable_sample_set";
3031
- sampleSize: number;
3032
- reviewedSampleSize: number;
3033
- rejectedSampleSize: number;
3034
- unreviewedSampleSize: number;
3035
- minReviewSampleSize: number;
3036
- reviewOutcomes: Record<string, number>;
3037
- hardGateReady: false;
3038
- notes: string[];
2937
+ providerKeys: {
2938
+ openai: boolean;
2939
+ anthropic: boolean;
2940
+ any: boolean;
2941
+ sources: {
2942
+ openai?: ProviderKeySource;
2943
+ anthropic?: ProviderKeySource;
2944
+ };
2945
+ envFilesLoaded: string[];
3039
2946
  };
3040
- recommendedActions: string[];
3041
- caveats: string[];
3042
- }
3043
- type WorkflowPlanPreset = "memory-backend-unification" | "project-intelligence-continuity-layer";
3044
- interface WorkflowPlanScaffoldDocument {
3045
- preset: WorkflowPlanPreset;
3046
- mode: "full";
3047
- goal: string;
3048
- steps: Array<{
3049
- id: string;
3050
- title: string;
3051
- query: string;
3052
- acceptance?: string;
3053
- files?: string[];
3054
- gates?: string[];
3055
- needs_runtime?: boolean;
3056
- }>;
3057
- }
3058
- interface ManagedWorkflowRuntimeCheckpoint {
3059
- summary: string;
3060
- capturedAt: string;
3061
- automationSessionId?: string;
3062
- hostedEventId?: string;
3063
- hostedRecordedAt?: string;
3064
- environment?: string;
3065
- profile?: string;
3066
- bootstrapQuery?: string;
3067
- files?: string[];
3068
- commands?: string[];
3069
- artifacts?: string[];
3070
- contextPackReceipts?: LocalContextPackReceiptPayload[];
3071
- rehydratableState?: Record<string, unknown>;
3072
- }
3073
- interface ManagedWorkflowSandboxRuntimeBinding {
3074
- phaseId: string;
3075
- sessionId: string;
3076
- automationSessionId?: string;
3077
- boundAt: string;
3078
- bootstrapQuery: string;
3079
- environment?: string;
3080
- profile?: string;
3081
- artifacts?: string[];
3082
- lastCheckpoint?: ManagedWorkflowRuntimeCheckpoint;
3083
- }
3084
- interface ManagedWorkflowRuntimeState {
3085
- sandbox?: {
3086
- provider: "snipara-sandbox";
3087
- bindings: ManagedWorkflowSandboxRuntimeBinding[];
2947
+ docker: {
2948
+ available: boolean;
3088
2949
  };
3089
2950
  }
3090
- interface ManagedWorkflowPhase {
2951
+ declare function detectRuntimeEnvironment(cwd?: string, env?: RuntimeEnvironment): RuntimeDetectionReport;
2952
+ declare function shouldSuggestRuntimeForWorkflow(query: string, mode: WorkflowMode): boolean;
2953
+ /**
2954
+ * Recommend whether work should be routed to snipara-orchestrator.
2955
+ *
2956
+ * Scores intent signals from the query and workflow mode (orchestrate mode,
2957
+ * production / proof / htask / multi-agent / parallel patterns) plus contextual
2958
+ * signals (changed-file count, active Team Sync collisions, policy auto-route).
2959
+ * The returned recommendation's level escalates with the accumulated score
2960
+ * (suggest → confirm → auto).
2961
+ *
2962
+ * @returns A recommendation with its reasons, or `null` when no signal fires.
2963
+ */
2964
+ declare function getOrchestratorRecommendation(query: string, mode: WorkflowMode, options?: OrchestratorRecommendationOptions): OrchestratorRecommendation | null;
2965
+ declare function formatOrchestratorRecommendationReason(reason: OrchestratorRecommendationReason): string;
2966
+ declare function shouldSuggestOrchestratorForWorkflow(query: string, mode: WorkflowMode): boolean;
2967
+
2968
+ declare const ORCHESTRATOR_HANDOFF_RELATIVE_PATH: string;
2969
+ interface OrchestratorHandoffWorkflowPhase {
3091
2970
  id: string;
3092
2971
  title: string;
3093
2972
  query: string;
3094
- status: ManagedWorkflowPhaseStatus;
2973
+ status: string;
3095
2974
  acceptance?: string;
3096
- files?: string[];
3097
- gates?: string[];
3098
- needsRuntime?: boolean;
3099
- startedAt?: string;
3100
- completedAt?: string;
3101
- summary?: string;
3102
- outcome?: TaskCommitOutcome;
3103
- }
3104
- interface ManagedWorkflowState {
3105
- schemaVersion: ManagedWorkflowSchemaVersion;
3106
- workflowId: string;
3107
- goal: string;
3108
- status: ManagedWorkflowStatus;
3109
- currentPhaseId?: string;
3110
- planSource: ManagedWorkflowPlanSource;
3111
- planFile?: string;
3112
- createdAt: string;
3113
- updatedAt: string;
3114
- phases: ManagedWorkflowPhase[];
3115
- runtime?: ManagedWorkflowRuntimeState;
3116
- lastCommit?: {
3117
- category: string;
3118
- outcome: TaskCommitOutcome;
3119
- summary: string;
3120
- committedAt: string;
3121
- };
3122
- }
3123
- interface AgenticWorkStatus {
3124
- version: "snipara.agentic_status.v1";
3125
- generatedAt: string;
3126
- branch?: string;
3127
- git: {
3128
- head?: string;
3129
- dirtyFileCount: number;
3130
- statusLines: string[];
3131
- error?: string;
3132
- };
3133
- workflow: {
3134
- id: string;
3135
- goal: string;
3136
- status: ManagedWorkflowStatus;
3137
- currentPhase?: {
3138
- id: string;
3139
- title: string;
3140
- status: ManagedWorkflowPhaseStatus;
3141
- };
3142
- lastPhaseCommit?: {
3143
- phaseId: string;
3144
- title: string;
3145
- summary?: string;
3146
- outcome?: TaskCommitOutcome;
3147
- completedAt?: string;
3148
- };
3149
- resumeCommand: string;
3150
- } | null;
3151
- teamSync: {
3152
- activeWorkCount: number;
3153
- staleWorkCount: number;
3154
- staleWorkExplanation: TeamSyncStaleWorkExplanation;
3155
- archivedWorkCount: number;
3156
- handoffCount: number;
3157
- latestHandoff?: {
3158
- summary: string;
3159
- next?: string;
3160
- attention?: string;
3161
- createdAt: string;
3162
- };
3163
- };
3164
- risks: string[];
3165
- openDecisions: {
3166
- count?: number;
3167
- note: string;
3168
- };
3169
- operationalLoop: {
3170
- status: "clear" | "attention" | "blocked";
3171
- decisionRequestCount: number;
3172
- receiptGapCount: number;
3173
- nextActions: string[];
3174
- receiptActions: string[];
3175
- caveats: string[];
3176
- };
3177
- suggestedNextAction: string;
2975
+ files: string[];
2976
+ gates: string[];
2977
+ needsRuntime: boolean;
3178
2978
  }
3179
- interface AgenticTimelineEvent {
3180
- time: string;
3181
- kind: string;
2979
+ interface OrchestratorHandoffRuntimeSandboxPhase {
2980
+ phaseId: string;
3182
2981
  title: string;
3183
- detail?: string;
3184
- source: ActivityEventSource;
3185
- files?: string[];
2982
+ bootstrapQuery: string;
2983
+ files: string[];
2984
+ artifacts: string[];
2985
+ contextPacks: string[];
2986
+ sessionId: string | null;
2987
+ environment: string | null;
2988
+ profile: string | null;
2989
+ hasCheckpoint: boolean;
2990
+ checkpointSummary: string | null;
2991
+ checkpointCapturedAt: string | null;
3186
2992
  }
3187
- interface AgenticTimeline {
3188
- version: "snipara.agentic_timeline.v1";
3189
- generatedAt: string;
3190
- events: AgenticTimelineEvent[];
3191
- limit: number;
2993
+ interface AdaptiveWorkProfile {
2994
+ taskType: string;
2995
+ risk: string;
2996
+ scope: string[];
2997
+ contextBudget: string;
2998
+ reasoningDepth: string;
2999
+ evidenceRequirements?: string[];
3000
+ preferredProfileStrengths?: string[];
3001
+ notes?: string[];
3192
3002
  }
3193
- interface WorkflowImpactGateCommit {
3194
- sha: string;
3195
- shortSha: string;
3196
- subject: string;
3197
- author?: string;
3198
- authoredAt?: string;
3003
+ interface AdaptiveModelRequirements {
3004
+ workerRole: string;
3005
+ reasoning: string;
3006
+ plannerRetainsReasoning: boolean;
3007
+ speed: string;
3008
+ cost: string;
3009
+ contextBudget: string;
3010
+ capabilities: string[];
3011
+ forbiddenCapabilities: string[];
3012
+ writeScope: string[];
3013
+ structuredOutputRequired?: boolean;
3014
+ preferredEndpointTypes?: string[];
3015
+ allowedEndpointTypes?: string[];
3016
+ catalogLimit?: number;
3017
+ dailyBudgetCents?: number;
3018
+ monthlyBudgetCents?: number;
3019
+ fallback: "main_agent";
3199
3020
  }
3200
- interface WorkflowImpactGatePhase {
3201
- id: string;
3202
- title: string;
3203
- summary?: string;
3204
- outcome?: TaskCommitOutcome;
3205
- completedAt?: string;
3206
- files: string[];
3207
- filesInUnpushedDiff: string[];
3021
+ interface AdaptiveRoutingCostEstimate {
3022
+ currency: "USD";
3023
+ confidence: "low" | "medium" | "high";
3208
3024
  }
3209
- interface WorkflowImpactGateResult {
3210
- version: "snipara.workflow_impact_gate.v1";
3211
- generatedAt: string;
3212
- gate: {
3213
- status: "pass" | "attention";
3214
- reasonCodes: string[];
3215
- };
3216
- repo: {
3217
- root: string;
3218
- branch?: string;
3219
- upstream: string;
3220
- baseSha?: string;
3221
- headSha?: string;
3222
- };
3223
- unpushed: {
3224
- commitCount: number;
3225
- commits: WorkflowImpactGateCommit[];
3226
- changedFiles: string[];
3227
- codeChangedFiles: string[];
3228
- nonCodeChangedFiles: string[];
3229
- };
3230
- dirtyWorkingTree: {
3231
- fileCount: number;
3232
- statusLines: string[];
3233
- files: string[];
3234
- includedInLocalImpact: false;
3235
- };
3236
- workflow: {
3237
- id?: string;
3238
- goal?: string;
3239
- status?: ManagedWorkflowStatus;
3240
- completedPhases: WorkflowImpactGatePhase[];
3241
- changedFilesWithoutPhase: string[];
3242
- phaseFilesOutsideUnpushedDiff: string[];
3243
- };
3244
- localImpact: Record<string, unknown> | null;
3245
- recommendedActions: string[];
3246
- caveats: string[];
3247
- hostedFollowUpCommand?: string;
3025
+ interface AdaptiveRoutingCard {
3026
+ mode: "dry_run";
3027
+ workProfile: AdaptiveWorkProfile;
3028
+ requirements: AdaptiveModelRequirements;
3029
+ recommendedWorkerClass: string;
3030
+ costEstimate: AdaptiveRoutingCostEstimate;
3031
+ humanApprovalRequired: boolean;
3032
+ fallback: "main_agent";
3033
+ rejectedReasons?: Record<string, string[]>;
3034
+ reasons: string[];
3035
+ warnings: string[];
3248
3036
  }
3249
- interface WorkflowPlanScaffoldResult {
3250
- preset: WorkflowPlanPreset;
3251
- goal: string;
3252
- outputPath: string;
3253
- relativeOutputPath: string;
3254
- plan: WorkflowPlanScaffoldDocument;
3037
+ interface AdaptiveRoutingGatewayStatus {
3038
+ source: "hosted_mcp" | "local_orchestrator";
3039
+ success: boolean;
3040
+ resolutionStatus?: string;
3041
+ candidateCount: number;
3042
+ fallback?: string;
3043
+ warnings: string[];
3255
3044
  }
3256
- interface SyncDocumentsManifestOptions {
3257
- metadataDefaults: Record<string, unknown>;
3258
- deleteMissing?: boolean;
3259
- dryRun?: boolean;
3260
- reindex?: boolean;
3261
- reindexKind?: ReindexKind;
3262
- reindexMode?: ReindexMode;
3045
+ interface AdaptiveRoutingRuntimeCatalog {
3046
+ version?: string;
3047
+ source?: string;
3048
+ provider?: string;
3049
+ baseUrl?: string;
3050
+ models?: string[];
3051
+ apiPaths?: Record<string, unknown>;
3052
+ workerEndpoints?: Record<string, Record<string, unknown>>;
3053
+ workerProfiles?: Record<string, Record<string, unknown>>;
3054
+ candidates: Array<Record<string, unknown>>;
3263
3055
  }
3264
- interface CollectedSyncDocuments {
3265
- documents: SyncDocumentInput[];
3266
- manifestOptions: SyncDocumentsManifestOptions;
3056
+ interface AdaptiveRoutingResolution {
3057
+ status?: string;
3058
+ selected?: Record<string, unknown>;
3059
+ policyDecision?: Record<string, unknown>;
3060
+ evaluatedCount?: number;
3061
+ rejectedCount?: number;
3062
+ fallback?: string;
3063
+ reasons?: string[];
3064
+ warnings?: string[];
3065
+ rejectedReasons?: Record<string, string[]>;
3267
3066
  }
3268
- interface SyncDocumentsDryRunItem {
3269
- path: string;
3270
- status: "valid" | "invalid_metadata";
3271
- recommended_action: "none" | "reupload" | "review_source_metadata";
3272
- reasons: string[];
3273
- kind?: SyncDocumentKind;
3274
- format?: string;
3275
- size_bytes: number;
3276
- content_hash: string;
3277
- assetClass?: string;
3278
- usageMode?: string;
3279
- sourceKind?: string;
3067
+ interface AdaptiveWorkRoutingRecommendation {
3068
+ workProfile: AdaptiveWorkProfile;
3069
+ requirements: AdaptiveModelRequirements;
3070
+ routingCard: AdaptiveRoutingCard;
3071
+ gateway?: AdaptiveRoutingGatewayStatus;
3072
+ runtimeCatalog?: AdaptiveRoutingRuntimeCatalog;
3073
+ resolution?: AdaptiveRoutingResolution;
3280
3074
  }
3281
- interface SyncDocumentsDryRunSummary {
3282
- dry_run: true;
3283
- remote_diff_available: false;
3284
- total: number;
3285
- would_sync: number;
3286
- invalid_metadata: number;
3287
- stale: number;
3288
- needs_reupload: number;
3289
- needs_metadata_review: number;
3290
- delete_missing: boolean;
3291
- reindex_requested: boolean;
3292
- reindex_kind: ReindexKind;
3293
- reindex_mode: ReindexMode;
3294
- created: null;
3295
- updated: null;
3296
- unchanged: null;
3297
- missing_from_manifest: null;
3298
- note: string;
3299
- documents: SyncDocumentsDryRunItem[];
3300
- }
3301
- interface OnboardFolderScannedFile {
3302
- path: string;
3303
- size_bytes: number;
3304
- supported: boolean;
3305
- kind?: SyncDocumentKind;
3306
- format?: string;
3307
- }
3308
- interface OnboardFolderClassification {
3309
- mode: DetectedOnboardFolderMode;
3310
- detected_mode: DetectedOnboardFolderMode;
3311
- confidence: number;
3312
- code_score: number;
3313
- business_score: number;
3314
- signals: {
3315
- code: string[];
3316
- business: string[];
3317
- };
3075
+ interface AdaptiveWorkRoutingOptions {
3076
+ query: string;
3077
+ mode?: string;
3078
+ changedFiles?: string[];
3079
+ preferredEndpointTypes?: string[];
3080
+ allowedEndpointTypes?: string[];
3081
+ workerRole?: string;
3082
+ plannerRetainsReasoning?: boolean;
3083
+ preferredProfileStrengths?: string[];
3084
+ structuredOutputRequired?: boolean;
3085
+ catalogLimit?: number;
3086
+ dailyBudgetCents?: number;
3087
+ monthlyBudgetCents?: number;
3318
3088
  }
3319
- interface OnboardFolderManifest {
3320
- schemaVersion: "snipara.onboard-folder.v1";
3089
+ interface OrchestratorHandoffArtifact {
3090
+ schemaVersion: "snipara.orchestrator.handoff.v1";
3321
3091
  source: {
3322
- root: string;
3323
- sourceKind: string;
3324
- sourceProvider: string;
3325
- sourceUri?: string;
3326
- snapshotAt: string;
3327
- recursive: boolean;
3092
+ client: "snipara-companion";
3093
+ command: string;
3094
+ generatedAt: string;
3328
3095
  };
3329
- classification: OnboardFolderClassification;
3330
- summary: {
3331
- total_files: number;
3332
- supported_documents: number;
3333
- ignored_files: number;
3334
- unsupported_business_files: number;
3096
+ workflow: {
3097
+ mode: string;
3098
+ workflowId: string | null;
3099
+ currentPhaseId: string | null;
3100
+ phases: OrchestratorHandoffWorkflowPhase[];
3335
3101
  };
3336
- warnings: string[];
3337
- ignored: OnboardFolderScannedFile[];
3338
- sync: {
3339
- dryRun: boolean;
3340
- reindex: boolean;
3341
- reindexKind: ReindexKind;
3342
- reindexMode: ReindexMode;
3343
- deleteMissing: boolean;
3344
- metadata: Record<string, unknown>;
3345
- documents: SyncDocumentInput[];
3102
+ runtime: {
3103
+ sandbox: {
3104
+ provider: "snipara-sandbox";
3105
+ phases: OrchestratorHandoffRuntimeSandboxPhase[];
3106
+ } | null;
3346
3107
  };
3347
- dryRun: SyncDocumentsDryRunSummary;
3348
- }
3349
- declare function getPlanStepDisplayTitle(step: unknown, index?: number): string;
3350
- interface PlanQualityReport {
3351
- valid: boolean;
3352
- issues: string[];
3353
- warnings: string[];
3354
- stepCount: number;
3355
- actions: string[];
3356
- planId?: string;
3357
- }
3358
- interface WorkflowTokenBudgetReport {
3359
- requested_max_tokens: number;
3360
- allocations: {
3361
- critical_memory_tokens: number;
3362
- session_context_tokens: number;
3363
- context_query_tokens: number;
3364
- shared_context_tokens: number;
3365
- plan_tokens: number;
3108
+ routing: {
3109
+ level: OrchestratorRecommendation["level"];
3110
+ reasons: OrchestratorRecommendation["reasons"];
3111
+ policySource: string | null;
3112
+ workProfile?: AdaptiveWorkProfile;
3113
+ requirements?: AdaptiveModelRequirements;
3114
+ routingCard?: AdaptiveRoutingCard;
3115
+ gateway?: AdaptiveRoutingGatewayStatus;
3116
+ runtimeCatalog?: AdaptiveRoutingRuntimeCatalog;
3117
+ resolution?: AdaptiveRoutingResolution;
3366
3118
  };
3367
- estimated_max_tokens: number;
3368
- include_session_context: boolean;
3369
- explicit: {
3370
- max_critical_tokens: boolean;
3371
- max_context_tokens: boolean;
3119
+ task: {
3120
+ title: string;
3121
+ query: string;
3122
+ summary: string;
3372
3123
  };
3373
- warnings: string[];
3374
- }
3375
- interface SessionBootstrapQualityReport {
3376
- warnings: string[];
3377
- counts: {
3378
- critical_memories: number;
3379
- session_context_memories: number;
3380
- low_confidence_memories: number;
3381
- stale_memories: number;
3382
- test_memories: number;
3124
+ repo: {
3125
+ root: string;
3126
+ branch: string | null;
3127
+ headSha: string | null;
3128
+ changedFiles: string[];
3129
+ };
3130
+ coordination: {
3131
+ swarmId: string | null;
3132
+ claimScope: {
3133
+ files: string[];
3134
+ symbols: string[];
3135
+ };
3136
+ htask: {
3137
+ featureTitle: string | null;
3138
+ workstreams: string[];
3139
+ };
3140
+ };
3141
+ validation: {
3142
+ requiresProofGate: boolean;
3143
+ requiresDriftCheck: boolean;
3144
+ liveChecks: string[];
3145
+ requiredEvidence: Array<{
3146
+ type: string;
3147
+ description: string;
3148
+ }>;
3149
+ };
3150
+ memory: {
3151
+ decisionIds: string[];
3152
+ contextRefs: string[];
3153
+ resumeSummary: string | null;
3383
3154
  };
3384
- total_tokens?: number;
3385
- oldest_memory_age_days?: number;
3386
3155
  }
3387
- interface SessionBootstrapBrief {
3388
- entries: SessionMemoryEntry[];
3389
- availableCount: number;
3390
- hiddenCount: number;
3391
- estimatedTokens: number;
3392
- budgetTokens: number;
3156
+ interface OrchestratorHandoffOptions {
3157
+ sourceCommand: string;
3158
+ recommendation: OrchestratorRecommendation;
3159
+ query: string;
3160
+ summary: string;
3161
+ title?: string;
3162
+ mode?: string;
3163
+ rootDir?: string;
3164
+ changedFiles?: string[];
3165
+ contextRefs?: string[];
3166
+ decisionIds?: string[];
3167
+ resumeSummary?: string;
3168
+ featureTitle?: string;
3169
+ workstreams?: string[];
3170
+ adaptiveRouting?: AdaptiveWorkRoutingRecommendation | null;
3393
3171
  }
3394
- interface GeneratedWorkflowPlanDocument {
3395
- mode: "full";
3396
- goal: string;
3397
- source: "snipara_plan";
3398
- plan_id?: string;
3399
- generatedAt: string;
3400
- steps: Array<{
3401
- id: string;
3402
- title: string;
3403
- query: string;
3404
- acceptance?: string;
3405
- files?: string[];
3406
- needs_runtime?: boolean;
3407
- }>;
3172
+ interface WrittenOrchestratorHandoff {
3173
+ handoff: OrchestratorHandoffArtifact;
3174
+ path: string;
3175
+ relativePath: string;
3176
+ command: string;
3408
3177
  }
3409
- declare function resolveFullWorkflowTokenBudget(options: {
3410
- maxTokens?: number;
3411
- includeSessionContext?: boolean;
3412
- includeSharedContext?: boolean;
3413
- maxCriticalTokens?: number;
3414
- maxContextTokens?: number;
3415
- }): WorkflowTokenBudgetReport;
3416
- declare function validatePlanResult(plan: unknown, options?: {
3417
- query?: string;
3178
+ declare function buildOrchestratorHandoff(options: OrchestratorHandoffOptions): OrchestratorHandoffArtifact;
3179
+ declare function buildAdaptiveWorkRoutingRecommendation(options: AdaptiveWorkRoutingOptions): AdaptiveWorkRoutingRecommendation;
3180
+ declare function writeOrchestratorHandoff(options: OrchestratorHandoffOptions): WrittenOrchestratorHandoff;
3181
+
3182
+ interface JournalCheckpointPayload {
3183
+ action: string;
3184
+ summary: string;
3185
+ outcome?: string;
3186
+ workflowId?: string;
3187
+ phaseId?: string;
3188
+ phaseTitle?: string;
3189
+ branch?: string;
3190
+ actor?: string;
3191
+ next?: string;
3192
+ attention?: string;
3193
+ files?: string[];
3418
3194
  cwd?: string;
3419
- }): PlanQualityReport;
3420
- declare function buildSessionBootstrapBrief(result: SessionMemoriesResult, options: {
3421
- includeSessionContext: boolean;
3422
- maxTokens?: number;
3423
- maxEntries?: number;
3195
+ }
3196
+ declare function buildJournalCheckpointEntry(payload: JournalCheckpointPayload): {
3197
+ text: string;
3198
+ tags: string[];
3199
+ };
3200
+
3201
+ declare const TEAM_SYNC_STATE_RELATIVE_PATH: string;
3202
+ type TeamSyncAttention = "note" | "watch" | "review" | "proof";
3203
+ type TeamSyncWorkStatus = "active" | "completed" | "archived";
3204
+ interface TeamSyncRecordInput {
3205
+ summary: string;
3206
+ files?: string[];
3207
+ branch?: string;
3208
+ actor?: string;
3209
+ next?: string;
3210
+ attention?: string;
3211
+ risk?: string;
3424
3212
  now?: Date;
3425
- }): SessionBootstrapBrief;
3426
- declare function buildSessionBootstrapQuality(result: SessionMemoriesResult, options?: {
3427
- expectedMaxTokens?: number;
3428
- now?: Date;
3429
- }): SessionBootstrapQualityReport;
3430
- declare function buildGeneratedWorkflowPlanDocument(plan: Record<string, unknown>, fallbackGoal: string): GeneratedWorkflowPlanDocument;
3431
- declare function normalizeWorkflowPlanInput(input: unknown, fallbackGoal: string): ManagedWorkflowPhase[];
3432
- declare function buildWorkflowPlanScaffold(preset: WorkflowPlanPreset, options?: {
3433
- goal?: string;
3434
- outputPath?: string;
3435
- cwd?: string;
3436
- }): WorkflowPlanScaffoldResult;
3437
- declare function writeProducerLoopArtifact(options: {
3438
- kind: ProducerLoopProducerKind;
3439
- command: "workflow phase-commit" | "workflow final-commit";
3440
- state?: ManagedWorkflowState;
3441
- phase?: ManagedWorkflowPhase;
3442
- category: string;
3443
- outcome: TaskCommitOutcome;
3213
+ }
3214
+ interface TeamSyncWorkRecord {
3215
+ id: string;
3216
+ type: "work";
3444
3217
  summary: string;
3445
- files?: string[];
3446
- journalAttempted: boolean;
3447
- teamSyncCompletionAttempted: boolean;
3448
- }): ProducerLoopArtifactWriteResult;
3449
- declare function buildProducerLoopReport(options?: {
3450
- cwd?: string;
3451
- minReviewSampleSize?: number;
3452
- }): ProducerLoopReport;
3453
- declare function buildWorkflowPhaseCommitSummary(args: {
3454
- workflowId: string;
3455
- phase: Pick<ManagedWorkflowPhase, "id" | "title">;
3218
+ files: string[];
3219
+ branch?: string;
3220
+ actor?: string;
3221
+ status: TeamSyncWorkStatus;
3222
+ createdAt: string;
3223
+ updatedAt: string;
3224
+ completedAt?: string;
3225
+ completionReason?: string;
3226
+ archivedAt?: string;
3227
+ archiveReason?: string;
3228
+ }
3229
+ interface TeamSyncHandoffRecord {
3230
+ id: string;
3231
+ type: "handoff";
3456
3232
  summary: string;
3457
- }): string;
3458
- declare function resolveAutoWorkflowMode(query: string): Exclude<WorkflowMode, "auto">;
3459
- /**
3460
- * Compute the impact gate for committed-but-unpushed workflow phases.
3461
- *
3462
- * Compares `upstream..HEAD`, separates unpushed code changes from non-code and
3463
- * dirty working-tree files, runs local code-overlay impact on the committed
3464
- * code files, and maps the result back to completed workflow phases. Surfaces
3465
- * reason codes such as `dirty_working_tree_not_included` and phase files that
3466
- * fall outside the unpushed diff, so a phase is not treated as verified on
3467
- * stale or partial evidence.
3468
- *
3469
- * @returns A `WorkflowImpactGateResult` with changed files, local impact,
3470
- * matched phases, and reason codes.
3471
- */
3472
- declare function buildWorkflowImpactGate(options?: {
3473
- cwd?: string;
3474
- base?: string;
3475
- maxFiles?: number;
3476
- }): WorkflowImpactGateResult;
3477
- declare function collectSyncDocuments(options: {
3478
- file?: string;
3479
- dir?: string;
3480
- prefix?: string;
3481
- recursive?: boolean;
3482
- }): SyncDocumentInput[];
3483
- declare function collectSyncDocumentsInput(options: {
3484
- file?: string;
3485
- dir?: string;
3486
- prefix?: string;
3487
- recursive?: boolean;
3488
- }): CollectedSyncDocuments;
3489
- interface OnboardFolderOptions {
3490
- dir: string;
3491
- recursive?: boolean;
3492
- mode?: OnboardFolderMode;
3493
- prefix?: string;
3494
- usageMode?: string;
3495
- sourceKind?: string;
3496
- sourceProvider?: string;
3497
- sourceUri?: string;
3498
- clientId?: string;
3499
- snapshotAt?: string;
3500
- deleteMissing?: boolean;
3501
- reindex?: boolean;
3502
- reindexKind?: ReindexKind;
3503
- reindexMode?: ReindexMode;
3233
+ files: string[];
3234
+ next?: string;
3235
+ attention?: TeamSyncAttention;
3236
+ actor?: string;
3237
+ createdAt: string;
3504
3238
  }
3505
- declare function buildOnboardFolderManifest(options: OnboardFolderOptions): OnboardFolderManifest;
3506
- declare function buildSyncDocumentsDryRun(documents: SyncDocumentInput[], options?: {
3507
- deleteMissing?: boolean;
3508
- reindex?: boolean;
3509
- reindexKind?: ReindexKind;
3510
- reindexMode?: ReindexMode;
3511
- now?: Date;
3512
- }): SyncDocumentsDryRunSummary;
3513
- declare function buildAgenticWorkStatus(cwd?: string): AgenticWorkStatus;
3514
- declare function buildAgenticTimeline(options?: {
3515
- limit?: number;
3516
- cwd?: string;
3517
- }): AgenticTimeline;
3518
-
3519
- type LocalSourceProvider = "local_folder";
3520
- type LocalSourceFileKind = "DOC" | "BINARY" | "CODE" | "CONFIG" | "OTHER";
3521
- type LocalSourceSkippedReason = "ignored" | "too_large" | "read_error";
3522
- type LocalSourceReindexKind = "doc" | "code";
3523
- type LocalSourceReindexMode = "incremental" | "full";
3524
- interface LocalSourceFile {
3525
- path: string;
3526
- kind: LocalSourceFileKind;
3527
- format: string | null;
3528
- sizeBytes: number;
3529
- modifiedAt: string;
3530
- sha256: string;
3239
+ interface TeamSyncState {
3240
+ schemaVersion: "snipara.team-sync.v1";
3241
+ updatedAt: string;
3242
+ work: TeamSyncWorkRecord[];
3243
+ handoffs: TeamSyncHandoffRecord[];
3531
3244
  }
3532
- interface LocalSourceSkippedFile {
3533
- path: string;
3534
- reason: LocalSourceSkippedReason;
3535
- sizeBytes?: number;
3245
+ interface TeamSyncSummary {
3246
+ activeWorkCount: number;
3247
+ staleWorkCount: number;
3248
+ completedWorkCount: number;
3249
+ archivedWorkCount: number;
3250
+ handoffCount: number;
3251
+ files: string[];
3252
+ staleWorkExplanation: TeamSyncStaleWorkExplanation;
3253
+ hygieneActions: TeamSyncHygieneAction[];
3254
+ latestActiveWork?: TeamSyncWorkRecord;
3255
+ latestStaleWork?: TeamSyncWorkRecord;
3256
+ latestCompletedWork?: TeamSyncWorkRecord;
3257
+ latestArchivedWork?: TeamSyncWorkRecord;
3258
+ latestHandoff?: TeamSyncHandoffRecord;
3536
3259
  }
3537
- interface LocalSourceSummary {
3538
- totalFiles: number;
3539
- totalBytes: number;
3540
- byKind: Record<LocalSourceFileKind, number>;
3541
- skipped: number;
3260
+ interface TeamSyncStaleWorkExplanation {
3261
+ staleAfterHours: number;
3262
+ autoArchiveAfterDays: number;
3263
+ activeStaleCount: number;
3264
+ autoArchivableCount: number;
3265
+ completedIgnoredCount: number;
3266
+ archivedIgnoredCount: number;
3267
+ latestStaleWorkAgeHours?: number;
3268
+ message: string;
3542
3269
  }
3543
- interface LocalSourceSnapshot {
3544
- version: "snipara.local_source_snapshot.v1";
3545
- generatedAt: string;
3546
- root: string;
3547
- provider: LocalSourceProvider;
3548
- revision: string;
3549
- recursive: boolean;
3550
- maxFiles: number;
3551
- maxFileBytes: number;
3552
- summary: LocalSourceSummary;
3553
- files: LocalSourceFile[];
3554
- skipped: {
3555
- total: number;
3556
- byReason: Record<LocalSourceSkippedReason, number>;
3557
- samples: LocalSourceSkippedFile[];
3558
- };
3559
- warnings: string[];
3270
+ interface TeamSyncHygieneAction {
3271
+ kind: "sweep-preview" | "sweep-archive" | "complete-work" | "handoff";
3272
+ command: string;
3273
+ reason: string;
3274
+ mutates: boolean;
3560
3275
  }
3561
- interface LocalSourceSnapshotOptions {
3276
+ interface TeamSyncCommandOptions {
3277
+ id?: string;
3278
+ summary?: string;
3279
+ files?: string[];
3280
+ branch?: string;
3281
+ actor?: string;
3282
+ next?: string;
3283
+ attention?: string;
3284
+ risk?: string;
3285
+ adapterPack?: boolean;
3286
+ adapterTarget?: string;
3287
+ context?: string[];
3288
+ proof?: string[];
3289
+ acceptance?: string[];
3290
+ conflictPosture?: string;
3291
+ since?: string;
3562
3292
  dir?: string;
3563
- recursive?: boolean;
3564
- maxFiles?: number;
3565
- maxFileBytes?: number;
3293
+ includeSessionContext?: boolean;
3294
+ emitOrchestratorHandoff?: boolean;
3295
+ autoRouteOrchestrator?: boolean;
3296
+ orchestratorPolicySource?: string;
3297
+ output?: string;
3298
+ days?: string;
3299
+ dryRun?: boolean;
3300
+ json?: boolean;
3566
3301
  }
3567
- interface LocalSourceComparison {
3568
- added: string[];
3569
- modified: string[];
3570
- deleted: string[];
3571
- unchanged: number;
3302
+ interface HostedAttempt<T> {
3303
+ status: "skipped" | "ok" | "error";
3304
+ data?: T;
3305
+ error?: string;
3572
3306
  }
3573
- interface LocalSourceStatusResult {
3574
- root: string;
3575
- snapshotPath: string;
3576
- previous: LocalSourceSnapshot | null;
3577
- current: LocalSourceSnapshot;
3578
- comparison: LocalSourceComparison;
3307
+ interface TeamSyncSweepResult {
3308
+ action: "sweep";
3309
+ statePath: string;
3310
+ dryRun: boolean;
3311
+ thresholdDays: number;
3312
+ thresholdMs: number;
3313
+ archivedCount: number;
3314
+ archivedWork: TeamSyncWorkRecord[];
3315
+ explanation: TeamSyncSweepExplanation;
3316
+ summary: TeamSyncSummary;
3579
3317
  }
3580
- interface LocalSourceSyncOptions extends LocalSourceSnapshotOptions {
3581
- prefix?: string;
3582
- mode?: OnboardFolderMode;
3583
- deleteMissing?: boolean;
3584
- apply?: boolean;
3585
- reindex?: boolean;
3586
- reindexKind?: LocalSourceReindexKind;
3587
- reindexMode?: LocalSourceReindexMode;
3588
- includeGraph?: boolean;
3589
- json?: boolean;
3318
+ interface TeamSyncSweepExplanation {
3319
+ mode: "preview" | "archive";
3320
+ candidateCount: number;
3321
+ archivedCount: number;
3322
+ remainingStaleCount: number;
3323
+ message: string;
3590
3324
  }
3591
- interface LocalSourceSyncResult {
3592
- root: string;
3593
- snapshotPath: string;
3594
- snapshot: LocalSourceSnapshot;
3595
- comparison: LocalSourceComparison;
3596
- documents: {
3597
- onboarding: Pick<OnboardFolderManifest, "source" | "classification" | "summary" | "warnings">;
3598
- dryRun: OnboardFolderManifest["dryRun"];
3325
+ type AgenticHandoffAdapterTarget = "codex" | "claude-code" | "cursor" | "orca" | "windsurf" | "custom";
3326
+ type AgenticHandoffConflictPosture = "continue" | "wait" | "split_work" | "review_only" | "handoff";
3327
+ interface AgenticHandoffAdapterPack {
3328
+ version: "snipara.ade_adapter_pack.v1";
3329
+ target: {
3330
+ id: AgenticHandoffAdapterTarget;
3331
+ label: string;
3332
+ profile: string;
3333
+ instruction: string;
3334
+ runtimeControl: "handoff_only";
3599
3335
  };
3600
- codeOverlay: {
3601
- cachePath: string;
3602
- summary: LocalCodeOverlaySummary;
3336
+ contextPack: {
3337
+ summary: string;
3338
+ files: string[];
3339
+ contextRefs: string[];
3340
+ workflow?: {
3341
+ goal?: string;
3342
+ status?: string;
3343
+ currentPhaseId?: string;
3344
+ currentPhaseTitle?: string;
3345
+ };
3346
+ resumeCommands: string[];
3347
+ constraints: string[];
3603
3348
  };
3604
- apply: null | {
3605
- sync: Record<string, unknown>;
3606
- reindex?: Record<string, unknown>;
3349
+ conflictPosture: AgenticHandoffConflictPosture;
3350
+ proofGates: string[];
3351
+ acceptanceCriteria: string[];
3352
+ receiptExpectation: {
3353
+ required: boolean;
3354
+ command: string;
3355
+ requiredFields: string[];
3607
3356
  };
3608
- warnings: string[];
3609
- }
3610
- declare function getLocalSourceSnapshotPath(cwd?: string): string;
3611
- declare function buildLocalSourceSnapshot(options?: LocalSourceSnapshotOptions): LocalSourceSnapshot;
3612
- declare function writeLocalSourceSnapshot(snapshot: LocalSourceSnapshot): string;
3613
- declare function readLocalSourceSnapshot(cwd?: string): LocalSourceSnapshot | null;
3614
- declare function compareLocalSourceSnapshots(previous: LocalSourceSnapshot | null, current: LocalSourceSnapshot): LocalSourceComparison;
3615
- declare function buildLocalSourceStatus(options?: LocalSourceSnapshotOptions): LocalSourceStatusResult;
3616
- declare function buildLocalSourceSyncResult(options?: LocalSourceSyncOptions): Promise<LocalSourceSyncResult>;
3617
-
3618
- interface LocalWorkerDeclaration {
3619
- id: string;
3620
- workerRole: string;
3621
- endpointType: "local";
3622
- provider: string;
3623
- baseUrl: string;
3624
- command?: string;
3625
- model?: string;
3626
- preferModel?: string;
3627
- capabilities: string[];
3628
- reasoning: "low" | "medium" | "high";
3629
- writeScope: string[];
3630
- createdAt: string;
3631
- updatedAt: string;
3357
+ prompt: string;
3358
+ caveats: string[];
3632
3359
  }
3633
- interface LocalWorkersConfig {
3634
- schemaVersion: "snipara.local_workers.v1";
3635
- updatedAt: string;
3636
- defaultWorkerId: string;
3637
- workers: LocalWorkerDeclaration[];
3360
+ interface TeamSyncCompletionEvidenceOptions {
3361
+ summary?: string;
3362
+ workflowGoal?: string;
3363
+ files?: string[];
3364
+ reason?: string;
3365
+ now?: Date;
3366
+ dryRun?: boolean;
3638
3367
  }
3639
- interface LocalWorkerRoutingDefaults {
3640
- worker: LocalWorkerDeclaration;
3641
- routeLocalWorkers: true;
3642
- routingWorkerRole: string;
3643
- routingLocalBaseUrl: string;
3644
- routingLocalModel?: string;
3645
- routingLocalPreferModel?: string;
3646
- routingLocalProvider: string;
3647
- routingPreferredEndpoints: string[];
3648
- routingAllowedEndpoints: string[];
3649
- plannerRetainsReasoning: true;
3368
+ interface AgenticHandoffArtifact {
3369
+ version: "snipara.agentic_handoff.v1";
3370
+ generatedAt: string;
3371
+ command: "snipara-companion handoff";
3372
+ record: TeamSyncHandoffRecord;
3373
+ statePath: string;
3374
+ hosted: {
3375
+ status: HostedAttempt<TeamSyncHandoffResponse>["status"];
3376
+ handoffId?: string;
3377
+ error?: string;
3378
+ };
3379
+ sections: {
3380
+ whatChanged: string[];
3381
+ verified: string[];
3382
+ risky: string[];
3383
+ remains: string[];
3384
+ whereToResume: string[];
3385
+ };
3386
+ suggestedCommands: string[];
3387
+ adapter?: AgenticHandoffAdapterPack;
3650
3388
  }
3651
- interface LocalWorkerAddOptions {
3652
- id?: string;
3653
- role?: string;
3654
- provider?: string;
3655
- baseUrl?: string;
3656
- model?: string;
3657
- preferModel?: string;
3658
- capabilities?: string[];
3659
- writeScope?: string[];
3660
- contextWindow?: number;
3661
- reasoning?: "low" | "medium" | "high";
3662
- default?: boolean;
3663
- json?: boolean;
3664
- transport?: "openai_http" | "cli";
3665
- command?: string;
3389
+ declare function buildTeamSyncStartWorkRecord(input: TeamSyncRecordInput): TeamSyncWorkRecord;
3390
+ declare function buildTeamSyncHandoffRecord(input: TeamSyncRecordInput): TeamSyncHandoffRecord;
3391
+ declare function createEmptyTeamSyncState(now?: Date): TeamSyncState;
3392
+ declare function buildTeamSyncSummary(state: TeamSyncState, since?: Date, now?: Date): TeamSyncSummary;
3393
+ declare function archiveInactiveTeamSyncWork(state: TeamSyncState, options?: {
3394
+ now?: Date;
3395
+ thresholdMs?: number;
3396
+ dryRun?: boolean;
3397
+ }): TeamSyncSweepResult["archivedWork"];
3398
+ declare function completeTeamSyncWorkFromEvidence(state: TeamSyncState, options?: TeamSyncCompletionEvidenceOptions): TeamSyncWorkRecord[];
3399
+ declare function completeTeamSyncStateFromEvidence(rootDir?: string, options?: TeamSyncCompletionEvidenceOptions): TeamSyncWorkRecord[];
3400
+ declare function autoArchiveTeamSyncState(rootDir?: string, now?: Date): TeamSyncSweepResult["archivedWork"];
3401
+ declare function loadTeamSyncState(rootDir?: string): TeamSyncState;
3402
+ declare function saveTeamSyncState(state: TeamSyncState, rootDir?: string): void;
3403
+ declare function getTeamSyncStatePath(rootDir?: string): string;
3404
+ declare function buildAgenticHandoffMarkdown(artifact: AgenticHandoffArtifact): string;
3405
+ declare function teamSyncSweepCommand(options: TeamSyncCommandOptions): Promise<void>;
3406
+
3407
+ type SyncDocumentKind = "DOC" | "BINARY";
3408
+ type WorkflowMode = "lite" | "standard" | "auto" | "full" | "orchestrate";
3409
+ type OnboardFolderMode = "auto" | "business_context" | "code_project" | "mixed";
3410
+ type DetectedOnboardFolderMode = "business_context" | "code_project" | "mixed" | "unknown";
3411
+ type ManagedWorkflowStatus = "active" | "completed" | "blocked";
3412
+ type ManagedWorkflowPhaseStatus = "pending" | "in_progress" | "completed" | "blocked" | "skipped";
3413
+ type ReindexKind = "doc" | "code";
3414
+ type ReindexMode = "incremental" | "full";
3415
+ type ManagedWorkflowPlanSource = "file" | "inline";
3416
+ type TaskCommitOutcome = "completed" | "partial" | "blocked" | "abandoned";
3417
+ type ManagedWorkflowSchemaVersion = "snipara.workflow.v1" | "snipara.workflow.v2";
3418
+ declare const WORKFLOW_STATE_RELATIVE_PATH: string;
3419
+ declare const WORKFLOW_PLANS_RELATIVE_DIR: string;
3420
+ declare const PRODUCER_LOOP_ARTIFACT_VERSION: "snipara.producer_loop_artifact.v0";
3421
+ declare const PRODUCER_LOOP_REPORT_VERSION: "snipara.producer_loop_report.v0";
3422
+ declare const PRODUCER_LOOP_RELATIVE_DIR: string;
3423
+ type ProducerLoopProducerKind = "workflow_phase_commit" | "workflow_final_commit" | "pr_answer_pack_decision_capture";
3424
+ type ProducerLoopSampleReviewStatus = "sample_unreviewed" | "sample_reviewed" | "sample_rejected";
3425
+ interface ProducerLoopArtifactWriteResult {
3426
+ status: "written" | "error";
3427
+ schemaVersion: typeof PRODUCER_LOOP_ARTIFACT_VERSION;
3428
+ artifactId?: string;
3429
+ path?: string;
3430
+ relativePath?: string;
3431
+ artifactHash?: string;
3432
+ ledgerHash?: string;
3433
+ error?: string;
3434
+ caveats: string[];
3666
3435
  }
3667
- interface LocalWorkerStatusOptions {
3668
- json?: boolean;
3436
+ interface ProducerLoopArtifactReportSummary {
3437
+ artifactId: string;
3438
+ generatedAt: string;
3439
+ producerKind: ProducerLoopProducerKind;
3440
+ workflowId?: string;
3441
+ phaseId?: string;
3442
+ phaseTitle?: string;
3443
+ outcome?: TaskCommitOutcome;
3444
+ summary?: string;
3445
+ path: string;
3446
+ relativePath: string;
3447
+ artifactHash: string;
3448
+ ledgerHash?: string;
3449
+ reasonCodes: string[];
3450
+ files: string[];
3451
+ calibrationStatus?: string;
3452
+ reviewStatus: ProducerLoopSampleReviewStatus;
3453
+ reviewOutcome?: string;
3454
+ reviewedAt?: string;
3455
+ reviewer?: string;
3669
3456
  }
3670
- interface LocalWorkerListOptions {
3671
- json?: boolean;
3457
+ interface ProducerLoopReport {
3458
+ version: typeof PRODUCER_LOOP_REPORT_VERSION;
3459
+ generatedAt: string;
3460
+ source: {
3461
+ directory: string;
3462
+ localOnly: true;
3463
+ };
3464
+ adoption: {
3465
+ status: "missing" | "active";
3466
+ artifactCount: number;
3467
+ producerKinds: ProducerLoopProducerKind[];
3468
+ workflowIds: string[];
3469
+ };
3470
+ artifacts: ProducerLoopArtifactReportSummary[];
3471
+ latestArtifact?: ProducerLoopArtifactReportSummary;
3472
+ invalidArtifacts: Array<{
3473
+ path: string;
3474
+ relativePath: string;
3475
+ error: string;
3476
+ }>;
3477
+ reasonCodes: {
3478
+ counts: Record<string, number>;
3479
+ };
3480
+ calibration: {
3481
+ status: "no_samples" | "insufficient_samples" | "reviewable_sample_set";
3482
+ sampleSize: number;
3483
+ reviewedSampleSize: number;
3484
+ rejectedSampleSize: number;
3485
+ unreviewedSampleSize: number;
3486
+ minReviewSampleSize: number;
3487
+ reviewOutcomes: Record<string, number>;
3488
+ hardGateReady: false;
3489
+ notes: string[];
3490
+ };
3491
+ recommendedActions: string[];
3492
+ caveats: string[];
3672
3493
  }
3673
- interface LocalWorkerRemoveOptions {
3674
- id: string;
3675
- json?: boolean;
3494
+ type WorkflowPlanPreset = "memory-backend-unification" | "project-intelligence-continuity-layer";
3495
+ interface WorkflowPlanScaffoldDocument {
3496
+ preset: WorkflowPlanPreset;
3497
+ mode: "full";
3498
+ goal: string;
3499
+ steps: Array<{
3500
+ id: string;
3501
+ title: string;
3502
+ query: string;
3503
+ acceptance?: string;
3504
+ files?: string[];
3505
+ gates?: string[];
3506
+ needs_runtime?: boolean;
3507
+ }>;
3676
3508
  }
3677
- interface LocalWorkerProbeOptions {
3678
- baseUrl?: string;
3679
- provider?: string;
3680
- model?: string;
3681
- preferModel?: string;
3682
- role?: string;
3683
- workerId?: string;
3684
- capabilities?: string[];
3685
- writeScope?: string[];
3686
- reasoning?: "low" | "medium" | "high";
3687
- contextWindow?: number;
3688
- json?: boolean;
3509
+ interface ManagedWorkflowRuntimeCheckpoint {
3510
+ summary: string;
3511
+ capturedAt: string;
3512
+ automationSessionId?: string;
3513
+ hostedEventId?: string;
3514
+ hostedRecordedAt?: string;
3515
+ environment?: string;
3516
+ profile?: string;
3517
+ bootstrapQuery?: string;
3518
+ files?: string[];
3519
+ commands?: string[];
3520
+ artifacts?: string[];
3521
+ contextPackReceipts?: LocalContextPackReceiptPayload[];
3522
+ rehydratableState?: Record<string, unknown>;
3689
3523
  }
3690
- declare function workersLocalAddCommand(options: LocalWorkerAddOptions): void;
3691
- declare function workersLocalStatusCommand(options?: LocalWorkerStatusOptions): void;
3692
- declare function workersLocalListCommand(options?: LocalWorkerListOptions): void;
3693
- declare function workersLocalRemoveCommand(options: LocalWorkerRemoveOptions): void;
3694
- declare function workersLocalProbePrintCommand(options: LocalWorkerProbeOptions): void;
3695
- declare function addLocalWorker(options: LocalWorkerAddOptions): {
3696
- worker: LocalWorkerDeclaration;
3697
- config: LocalWorkersConfig;
3698
- workerConfigPath: string;
3699
- policyPath: string;
3700
- };
3701
- declare function resolveLocalWorkerRoutingDefaults(options?: {
3702
- workerId?: string;
3703
- workerRole?: string;
3704
- }): LocalWorkerRoutingDefaults | null;
3705
- declare function readLocalWorkersConfig(): LocalWorkersConfig | null;
3706
-
3707
- interface ControlledWorkerExecuteOptions {
3708
- task: string;
3709
- workerId?: string;
3710
- workerRole?: string;
3711
- endpointType?: "local" | "cloud" | "self_hosted" | "unknown";
3712
- mode?: ControlledWorkerExecutionMode;
3713
- command?: string;
3714
- execute?: boolean;
3715
- approvalReceipt?: string;
3716
- outcomeReceipt?: string;
3717
- writeScope?: string[];
3718
- acceptance?: string[];
3719
- proof?: string[];
3720
- output?: string;
3721
- projectId?: string;
3722
- unifiedOutput?: string;
3723
- dir?: string;
3724
- json?: boolean;
3524
+ interface ManagedWorkflowSandboxRuntimeBinding {
3525
+ phaseId: string;
3526
+ sessionId: string;
3527
+ automationSessionId?: string;
3528
+ boundAt: string;
3529
+ bootstrapQuery: string;
3530
+ environment?: string;
3531
+ profile?: string;
3532
+ artifacts?: string[];
3533
+ lastCheckpoint?: ManagedWorkflowRuntimeCheckpoint;
3725
3534
  }
3726
- interface ControlledWorkerExecuteResult {
3727
- executed: boolean;
3728
- blocked: boolean;
3729
- receiptPath: string;
3730
- unifiedReceiptPath: string | null;
3731
- receipt: ControlledWorkerExecutionReceipt;
3732
- unifiedReceipt: UnifiedReceiptEnvelope<ControlledWorkerExecutionReceipt> | null;
3535
+ interface ManagedWorkflowRuntimeState {
3536
+ sandbox?: {
3537
+ provider: "snipara-sandbox";
3538
+ bindings: ManagedWorkflowSandboxRuntimeBinding[];
3539
+ };
3733
3540
  }
3734
- declare function controlledWorkerExecuteCommand(options: ControlledWorkerExecuteOptions): ControlledWorkerExecuteResult;
3735
-
3736
- declare const MANIFEST_VERSION = "snipara.references.v1";
3737
- type ReferenceStatus = "allowed" | "pending" | "denied" | "unsupported";
3738
- interface ReferenceOccurrence {
3739
- file: string;
3740
- line: number;
3741
- label?: string;
3541
+ type ManagedWorkflowCoordinationMode = "standard" | "full" | "orchestrate";
3542
+ interface ManagedWorkflowCoordinationState {
3543
+ mode: ManagedWorkflowCoordinationMode;
3544
+ autoPublish: boolean;
3545
+ startedAt?: string;
3546
+ lastUpdatedAt?: string;
3547
+ workSessionId?: string;
3548
+ startReceipt?: WorkflowCollaborationReceipt;
3549
+ teamSyncReceipt?: Record<string, unknown>;
3550
+ releaseReceipt?: WorkflowCollaborationReceipt;
3742
3551
  }
3743
- interface ReferenceManifestItem {
3552
+ interface ManagedWorkflowPhase {
3744
3553
  id: string;
3745
- url: string;
3746
- normalizedUrl: string;
3747
- domain: string;
3748
- status: ReferenceStatus;
3749
- reason: string;
3750
- discoveredAt: string;
3751
- occurrences: ReferenceOccurrence[];
3752
- latestSnapshotPath?: string;
3753
- latestFetchStatus?: number;
3754
- latestFetchAt?: string;
3755
- latestContentHash?: string;
3756
- latestError?: string;
3554
+ title: string;
3555
+ query: string;
3556
+ status: ManagedWorkflowPhaseStatus;
3557
+ acceptance?: string;
3558
+ files?: string[];
3559
+ gates?: string[];
3560
+ needsRuntime?: boolean;
3561
+ startedAt?: string;
3562
+ completedAt?: string;
3563
+ summary?: string;
3564
+ outcome?: TaskCommitOutcome;
3757
3565
  }
3758
- interface ReferenceManifest {
3759
- version: typeof MANIFEST_VERSION;
3760
- generatedAt: string;
3761
- root: string;
3762
- allowDomains: string[];
3763
- denyDomains: string[];
3764
- items: ReferenceManifestItem[];
3566
+ interface ManagedWorkflowState {
3567
+ schemaVersion: ManagedWorkflowSchemaVersion;
3568
+ workflowId: string;
3569
+ goal: string;
3570
+ status: ManagedWorkflowStatus;
3571
+ currentPhaseId?: string;
3572
+ planSource: ManagedWorkflowPlanSource;
3573
+ planFile?: string;
3574
+ createdAt: string;
3575
+ updatedAt: string;
3576
+ phases: ManagedWorkflowPhase[];
3577
+ runtime?: ManagedWorkflowRuntimeState;
3578
+ coordination?: ManagedWorkflowCoordinationState;
3579
+ lastCommit?: {
3580
+ category: string;
3581
+ outcome: TaskCommitOutcome;
3582
+ summary: string;
3583
+ committedAt: string;
3584
+ };
3765
3585
  }
3766
- interface ScanReferencesOptions {
3767
- root?: string;
3768
- output?: string;
3769
- allowDomain?: string[];
3770
- denyDomain?: string[];
3771
- extensions?: string[];
3772
- maxFiles?: number;
3773
- json?: boolean;
3586
+ interface AgenticWorkStatus {
3587
+ version: "snipara.agentic_status.v1";
3588
+ generatedAt: string;
3589
+ branch?: string;
3590
+ git: {
3591
+ head?: string;
3592
+ dirtyFileCount: number;
3593
+ statusLines: string[];
3594
+ error?: string;
3595
+ };
3596
+ workflow: {
3597
+ id: string;
3598
+ goal: string;
3599
+ status: ManagedWorkflowStatus;
3600
+ currentPhase?: {
3601
+ id: string;
3602
+ title: string;
3603
+ status: ManagedWorkflowPhaseStatus;
3604
+ };
3605
+ lastPhaseCommit?: {
3606
+ phaseId: string;
3607
+ title: string;
3608
+ summary?: string;
3609
+ outcome?: TaskCommitOutcome;
3610
+ completedAt?: string;
3611
+ };
3612
+ resumeCommand: string;
3613
+ } | null;
3614
+ teamSync: {
3615
+ activeWorkCount: number;
3616
+ staleWorkCount: number;
3617
+ staleWorkExplanation: TeamSyncStaleWorkExplanation;
3618
+ archivedWorkCount: number;
3619
+ handoffCount: number;
3620
+ latestHandoff?: {
3621
+ summary: string;
3622
+ next?: string;
3623
+ attention?: string;
3624
+ createdAt: string;
3625
+ };
3626
+ };
3627
+ risks: string[];
3628
+ openDecisions: {
3629
+ count?: number;
3630
+ note: string;
3631
+ };
3632
+ operationalLoop: {
3633
+ status: "clear" | "attention" | "blocked";
3634
+ decisionRequestCount: number;
3635
+ receiptGapCount: number;
3636
+ nextActions: string[];
3637
+ receiptActions: string[];
3638
+ caveats: string[];
3639
+ };
3640
+ suggestedNextAction: string;
3774
3641
  }
3775
- interface IngestReferencesOptions {
3776
- manifest?: string;
3777
- outputDir?: string;
3778
- allowDomain?: string[];
3779
- ids?: string[];
3780
- max?: number;
3781
- timeoutMs?: number;
3782
- maxBytes?: number;
3783
- destinationPrefix?: string;
3784
- upload?: boolean;
3785
- reindex?: boolean;
3786
- dryRun?: boolean;
3787
- json?: boolean;
3642
+ interface AgenticTimelineEvent {
3643
+ time: string;
3644
+ kind: string;
3645
+ title: string;
3646
+ detail?: string;
3647
+ source: ActivityEventSource;
3648
+ files?: string[];
3788
3649
  }
3789
- interface ScanSummary {
3790
- manifest: ReferenceManifest;
3791
- outputPath: string;
3792
- scannedFiles: number;
3793
- foundUrls: number;
3794
- allowed: number;
3795
- pending: number;
3796
- denied: number;
3797
- unsupported: number;
3650
+ interface AgenticTimeline {
3651
+ version: "snipara.agentic_timeline.v1";
3652
+ generatedAt: string;
3653
+ events: AgenticTimelineEvent[];
3654
+ limit: number;
3798
3655
  }
3799
- interface IngestSummary {
3800
- manifestPath: string;
3801
- selected: number;
3802
- fetched: number;
3803
- uploaded: number;
3804
- failed: number;
3805
- dryRun: boolean;
3806
- snapshots: Array<{
3807
- id: string;
3808
- url: string;
3809
- snapshotPath?: string;
3810
- destinationPath?: string;
3811
- status?: number;
3812
- uploaded?: boolean;
3813
- error?: string;
3814
- }>;
3656
+ interface WorkflowImpactGateCommit {
3657
+ sha: string;
3658
+ shortSha: string;
3659
+ subject: string;
3660
+ author?: string;
3661
+ authoredAt?: string;
3815
3662
  }
3816
- declare function scanReferences(options?: ScanReferencesOptions): ScanSummary;
3817
- declare function ingestReferences(options?: IngestReferencesOptions): Promise<IngestSummary>;
3818
- declare function referencesScanCommand(options: ScanReferencesOptions): Promise<void>;
3819
- declare function referencesIngestCommand(options: IngestReferencesOptions): Promise<void>;
3820
-
3821
- declare const POLICY_LEDGER_SYNC_REPORT_VERSION: "snipara.workflow_policy_ledger_sync.v0";
3822
- interface PolicyLedgerSyncSummary {
3823
- total: number;
3824
- pendingRequests: number;
3825
- resolvedDecisions: number;
3826
- applyReceipts: number;
3827
- policyDrafts: number;
3663
+ interface WorkflowImpactGatePhase {
3664
+ id: string;
3665
+ title: string;
3666
+ summary?: string;
3667
+ outcome?: TaskCommitOutcome;
3668
+ completedAt?: string;
3669
+ files: string[];
3670
+ filesInUnpushedDiff: string[];
3828
3671
  }
3829
- interface PolicyLedgerSyncReport {
3830
- version: typeof POLICY_LEDGER_SYNC_REPORT_VERSION;
3672
+ interface WorkflowImpactGateResult {
3673
+ version: "snipara.workflow_impact_gate.v1";
3831
3674
  generatedAt: string;
3832
- dryRun: boolean;
3833
- summary: PolicyLedgerSyncSummary;
3834
- artifacts: ProjectPolicyLedgerSyncArtifactInput[];
3835
- hosted?: Record<string, unknown>;
3675
+ gate: {
3676
+ status: "pass" | "attention";
3677
+ reasonCodes: string[];
3678
+ };
3679
+ repo: {
3680
+ root: string;
3681
+ branch?: string;
3682
+ upstream: string;
3683
+ baseSha?: string;
3684
+ headSha?: string;
3685
+ };
3686
+ unpushed: {
3687
+ commitCount: number;
3688
+ commits: WorkflowImpactGateCommit[];
3689
+ changedFiles: string[];
3690
+ codeChangedFiles: string[];
3691
+ nonCodeChangedFiles: string[];
3692
+ };
3693
+ dirtyWorkingTree: {
3694
+ fileCount: number;
3695
+ statusLines: string[];
3696
+ files: string[];
3697
+ includedInLocalImpact: false;
3698
+ };
3699
+ workflow: {
3700
+ id?: string;
3701
+ goal?: string;
3702
+ status?: ManagedWorkflowStatus;
3703
+ completedPhases: WorkflowImpactGatePhase[];
3704
+ changedFilesWithoutPhase: string[];
3705
+ phaseFilesOutsideUnpushedDiff: string[];
3706
+ };
3707
+ localImpact: Record<string, unknown> | null;
3708
+ recommendedActions: string[];
3836
3709
  caveats: string[];
3710
+ hostedFollowUpCommand?: string;
3837
3711
  }
3838
- declare function buildPolicyLedgerSyncReport(options?: {
3839
- cwd?: string;
3840
- dryRun?: boolean;
3841
- }): PolicyLedgerSyncReport;
3842
- declare function workflowSyncPolicyLedgerCommand(options: {
3843
- dryRun?: boolean;
3844
- json?: boolean;
3845
- }): Promise<void>;
3846
- declare function collectPolicyLedgerSyncArtifacts(cwd?: string): ProjectPolicyLedgerSyncArtifactInput[];
3847
-
3848
- type CacheStrategy = "exact" | "nearby" | "warm";
3849
- interface QueryCacheScope {
3850
- cwd?: string;
3851
- projectId?: string;
3852
- sessionId?: string;
3853
- }
3854
- interface QueryCacheLookup {
3855
- query: string;
3856
- maxTokens: number;
3857
- }
3858
- interface QueryCacheHit {
3859
- strategy: CacheStrategy;
3860
- result: ContextQueryResult;
3861
- sourceQuery: string;
3862
- similarity?: number;
3712
+ interface WorkflowPlanScaffoldResult {
3713
+ preset: WorkflowPlanPreset;
3714
+ goal: string;
3715
+ outputPath: string;
3716
+ relativeOutputPath: string;
3717
+ plan: WorkflowPlanScaffoldDocument;
3863
3718
  }
3864
- interface WarmSnapshotResult {
3865
- storedEntries: number;
3866
- fileName?: string;
3719
+ interface SyncDocumentsManifestOptions {
3720
+ metadataDefaults: Record<string, unknown>;
3721
+ deleteMissing?: boolean;
3722
+ dryRun?: boolean;
3723
+ reindex?: boolean;
3724
+ reindexKind?: ReindexKind;
3725
+ reindexMode?: ReindexMode;
3867
3726
  }
3868
- declare class LocalQueryCache {
3869
- private readonly scope;
3870
- private readonly ttlMs;
3871
- private readonly warmTtlMs;
3872
- private readonly maxEntries;
3873
- private readonly maxBytes;
3874
- constructor(scope?: QueryCacheScope);
3875
- lookup(options: QueryCacheLookup): QueryCacheHit | null;
3876
- save(options: QueryCacheLookup, result: ContextQueryResult): void;
3877
- storeWarmSnapshot(result: SessionMemoriesResult): WarmSnapshotResult;
3878
- clear(): number;
3879
- private loadIndex;
3880
- private persistIndex;
3881
- private pruneIndex;
3882
- private readEntry;
3883
- private findNearbyEntry;
3884
- private lookupWarmSnapshot;
3727
+ interface CollectedSyncDocuments {
3728
+ documents: SyncDocumentInput[];
3729
+ manifestOptions: SyncDocumentsManifestOptions;
3885
3730
  }
3886
- declare function createLocalQueryCache(scope?: QueryCacheScope): LocalQueryCache;
3887
-
3888
- declare const AUTOMATION_MANIFEST_RELATIVE_PATH = ".snipara/automations/manifest.json";
3889
- type AutomationFileState = "create" | "update" | "unchanged" | "conflict";
3890
- interface AutomationManifestFile {
3731
+ interface SyncDocumentsDryRunItem {
3891
3732
  path: string;
3892
- sha256: string;
3733
+ status: "valid" | "invalid_metadata";
3734
+ recommended_action: "none" | "reupload" | "review_source_metadata";
3735
+ reasons: string[];
3736
+ kind?: SyncDocumentKind;
3737
+ format?: string;
3738
+ size_bytes: number;
3739
+ content_hash: string;
3740
+ assetClass?: string;
3741
+ usageMode?: string;
3742
+ sourceKind?: string;
3893
3743
  }
3894
- interface AutomationManifest {
3895
- version: number;
3896
- client: string;
3897
- projectId?: string;
3898
- apiUrl?: string;
3899
- installedAt: string;
3900
- files: AutomationManifestFile[];
3744
+ interface SyncDocumentsDryRunSummary {
3745
+ dry_run: true;
3746
+ remote_diff_available: false;
3747
+ total: number;
3748
+ would_sync: number;
3749
+ invalid_metadata: number;
3750
+ stale: number;
3751
+ needs_reupload: number;
3752
+ needs_metadata_review: number;
3753
+ delete_missing: boolean;
3754
+ reindex_requested: boolean;
3755
+ reindex_kind: ReindexKind;
3756
+ reindex_mode: ReindexMode;
3757
+ created: null;
3758
+ updated: null;
3759
+ unchanged: null;
3760
+ missing_from_manifest: null;
3761
+ note: string;
3762
+ documents: SyncDocumentsDryRunItem[];
3901
3763
  }
3902
- interface AutomationFilePlan {
3764
+ interface OnboardFolderScannedFile {
3903
3765
  path: string;
3904
- targetPath: string;
3905
- state: AutomationFileState;
3906
- reason: string;
3907
- currentSha256?: string;
3908
- previousSha256?: string;
3909
- nextSha256: string;
3910
- writeContent?: string;
3911
- }
3912
- interface AutomationInstallResult {
3913
- manifest: AutomationManifest;
3914
- plan: AutomationFilePlan[];
3915
- written: number;
3916
- unchanged: number;
3917
- dryRun: boolean;
3766
+ size_bytes: number;
3767
+ supported: boolean;
3768
+ kind?: SyncDocumentKind;
3769
+ format?: string;
3918
3770
  }
3919
- interface AutomationStatusResult {
3920
- manifest: AutomationManifest | null;
3921
- files: Array<{
3922
- path: string;
3923
- targetPath: string;
3924
- state: "up-to-date" | "modified" | "missing";
3925
- expectedSha256: string;
3926
- currentSha256?: string;
3927
- }>;
3771
+ interface OnboardFolderClassification {
3772
+ mode: DetectedOnboardFolderMode;
3773
+ detected_mode: DetectedOnboardFolderMode;
3774
+ confidence: number;
3775
+ code_score: number;
3776
+ business_score: number;
3777
+ signals: {
3778
+ code: string[];
3779
+ business: string[];
3780
+ };
3928
3781
  }
3929
- declare class AutomationInstallConflictError extends Error {
3930
- conflicts: AutomationFilePlan[];
3931
- constructor(conflicts: AutomationFilePlan[]);
3782
+ interface OnboardFolderManifest {
3783
+ schemaVersion: "snipara.onboard-folder.v1";
3784
+ source: {
3785
+ root: string;
3786
+ sourceKind: string;
3787
+ sourceProvider: string;
3788
+ sourceUri?: string;
3789
+ snapshotAt: string;
3790
+ recursive: boolean;
3791
+ };
3792
+ classification: OnboardFolderClassification;
3793
+ summary: {
3794
+ total_files: number;
3795
+ supported_documents: number;
3796
+ ignored_files: number;
3797
+ unsupported_business_files: number;
3798
+ };
3799
+ warnings: string[];
3800
+ ignored: OnboardFolderScannedFile[];
3801
+ sync: {
3802
+ dryRun: boolean;
3803
+ reindex: boolean;
3804
+ reindexKind: ReindexKind;
3805
+ reindexMode: ReindexMode;
3806
+ deleteMissing: boolean;
3807
+ metadata: Record<string, unknown>;
3808
+ documents: SyncDocumentInput[];
3809
+ };
3810
+ dryRun: SyncDocumentsDryRunSummary;
3932
3811
  }
3933
- declare class AutomationUnsupportedHookBundleError extends Error {
3934
- client: string;
3935
- files: string[];
3936
- constructor(client: string, files: string[]);
3812
+ declare function getPlanStepDisplayTitle(step: unknown, index?: number): string;
3813
+ interface PlanQualityReport {
3814
+ valid: boolean;
3815
+ issues: string[];
3816
+ warnings: string[];
3817
+ stepCount: number;
3818
+ actions: string[];
3819
+ planId?: string;
3937
3820
  }
3938
- declare function getAutomationManifestPath(projectDir?: string): string;
3939
- declare function loadAutomationManifest(projectDir?: string): AutomationManifest | null;
3940
- declare function buildAutomationInstallPlan(args: {
3941
- projectDir: string;
3942
- bundle: AutomationConfigBundle;
3943
- manifest?: AutomationManifest | null;
3944
- force?: boolean;
3945
- }): AutomationFilePlan[];
3946
- declare function installAutomationBundle(args: {
3947
- client: string;
3948
- projectDir?: string;
3949
- bundle?: AutomationConfigBundle;
3950
- force?: boolean;
3951
- dryRun?: boolean;
3952
- }): Promise<AutomationInstallResult>;
3953
- declare function getAutomationStatus(projectDir?: string): AutomationStatusResult;
3954
-
3955
- declare const COLLABORATION_STATE_RELATIVE_PATH: string;
3956
- type CollaborationGuardActionKind = "safe_to_ack" | "needs_handoff" | "needs_test" | "needs_package_review" | "blocking_conflict" | "guard_unavailable";
3957
- interface CollaborationGuardActionCard {
3958
- kind: CollaborationGuardActionKind;
3959
- title: string;
3960
- reason: string;
3961
- severity: "info" | "watch" | "warning" | "critical";
3962
- safeToAck: boolean;
3963
- command?: string;
3964
- conflictCode?: string;
3965
- resource?: string;
3821
+ interface WorkflowTokenBudgetReport {
3822
+ requested_max_tokens: number;
3823
+ allocations: {
3824
+ critical_memory_tokens: number;
3825
+ session_context_tokens: number;
3826
+ context_query_tokens: number;
3827
+ shared_context_tokens: number;
3828
+ plan_tokens: number;
3829
+ };
3830
+ estimated_max_tokens: number;
3831
+ include_session_context: boolean;
3832
+ explicit: {
3833
+ max_critical_tokens: boolean;
3834
+ max_context_tokens: boolean;
3835
+ };
3836
+ warnings: string[];
3966
3837
  }
3967
- interface CollaborationCommandOptions {
3968
- summary?: string;
3838
+ interface SessionBootstrapQualityReport {
3839
+ warnings: string[];
3840
+ counts: {
3841
+ critical_memories: number;
3842
+ session_context_memories: number;
3843
+ low_confidence_memories: number;
3844
+ stale_memories: number;
3845
+ test_memories: number;
3846
+ };
3847
+ total_tokens?: number;
3848
+ oldest_memory_age_days?: number;
3849
+ }
3850
+ interface SessionBootstrapBrief {
3851
+ entries: SessionMemoryEntry[];
3852
+ availableCount: number;
3853
+ hiddenCount: number;
3854
+ estimatedTokens: number;
3855
+ budgetTokens: number;
3856
+ }
3857
+ interface GeneratedWorkflowPlanDocument {
3858
+ mode: "full";
3859
+ goal: string;
3860
+ source: "snipara_plan";
3861
+ plan_id?: string;
3862
+ generatedAt: string;
3863
+ steps: Array<{
3864
+ id: string;
3865
+ title: string;
3866
+ query: string;
3867
+ acceptance?: string;
3868
+ files?: string[];
3869
+ needs_runtime?: boolean;
3870
+ }>;
3871
+ }
3872
+ declare function resolveFullWorkflowTokenBudget(options: {
3873
+ maxTokens?: number;
3874
+ includeSessionContext?: boolean;
3875
+ includeSharedContext?: boolean;
3876
+ maxCriticalTokens?: number;
3877
+ maxContextTokens?: number;
3878
+ }): WorkflowTokenBudgetReport;
3879
+ declare function validatePlanResult(plan: unknown, options?: {
3880
+ query?: string;
3881
+ cwd?: string;
3882
+ }): PlanQualityReport;
3883
+ declare function buildSessionBootstrapBrief(result: SessionMemoriesResult, options: {
3884
+ includeSessionContext: boolean;
3885
+ maxTokens?: number;
3886
+ maxEntries?: number;
3887
+ now?: Date;
3888
+ }): SessionBootstrapBrief;
3889
+ declare function buildSessionBootstrapQuality(result: SessionMemoriesResult, options?: {
3890
+ expectedMaxTokens?: number;
3891
+ now?: Date;
3892
+ }): SessionBootstrapQualityReport;
3893
+ declare function buildGeneratedWorkflowPlanDocument(plan: Record<string, unknown>, fallbackGoal: string): GeneratedWorkflowPlanDocument;
3894
+ declare function normalizeWorkflowPlanInput(input: unknown, fallbackGoal: string): ManagedWorkflowPhase[];
3895
+ declare function buildWorkflowPlanScaffold(preset: WorkflowPlanPreset, options?: {
3896
+ goal?: string;
3897
+ outputPath?: string;
3898
+ cwd?: string;
3899
+ }): WorkflowPlanScaffoldResult;
3900
+ declare function writeProducerLoopArtifact(options: {
3901
+ kind: ProducerLoopProducerKind;
3902
+ command: "workflow phase-commit" | "workflow final-commit";
3903
+ state?: ManagedWorkflowState;
3904
+ phase?: ManagedWorkflowPhase;
3905
+ category: string;
3906
+ outcome: TaskCommitOutcome;
3907
+ summary: string;
3969
3908
  files?: string[];
3970
- resources?: string[];
3971
- actor?: string;
3972
- actorId?: string;
3973
- actorType?: string;
3974
- sessionId?: string;
3975
- workSessionId?: string;
3976
- swarmId?: string;
3977
- client?: string;
3978
- repository?: string;
3979
- branch?: string;
3980
- worktree?: string;
3981
- action?: string;
3982
- profile?: string;
3983
- mode?: string;
3984
- reason?: string;
3985
- ttlSeconds?: string;
3986
- heartbeatTtlSeconds?: string;
3987
- intervalSeconds?: string;
3988
- maxFiles?: string;
3989
- leaseId?: string;
3990
- all?: boolean;
3991
- once?: boolean;
3992
- autoClaim?: boolean;
3993
- releaseStale?: boolean;
3994
- persist?: boolean;
3995
- enforce?: boolean;
3996
- ackReviewOnly?: boolean;
3909
+ journalAttempted: boolean;
3910
+ teamSyncCompletionAttempted: boolean;
3911
+ }): ProducerLoopArtifactWriteResult;
3912
+ declare function buildProducerLoopReport(options?: {
3913
+ cwd?: string;
3914
+ minReviewSampleSize?: number;
3915
+ }): ProducerLoopReport;
3916
+ declare function buildWorkflowPhaseCommitSummary(args: {
3917
+ workflowId: string;
3918
+ phase: Pick<ManagedWorkflowPhase, "id" | "title">;
3919
+ summary: string;
3920
+ }): string;
3921
+ declare function resolveAutoWorkflowMode(query: string): Exclude<WorkflowMode, "auto">;
3922
+ /**
3923
+ * Compute the impact gate for committed-but-unpushed workflow phases.
3924
+ *
3925
+ * Compares `upstream..HEAD`, separates unpushed code changes from non-code and
3926
+ * dirty working-tree files, runs local code-overlay impact on the committed
3927
+ * code files, and maps the result back to completed workflow phases. Surfaces
3928
+ * reason codes such as `dirty_working_tree_not_included` and phase files that
3929
+ * fall outside the unpushed diff, so a phase is not treated as verified on
3930
+ * stale or partial evidence.
3931
+ *
3932
+ * @returns A `WorkflowImpactGateResult` with changed files, local impact,
3933
+ * matched phases, and reason codes.
3934
+ */
3935
+ declare function buildWorkflowImpactGate(options?: {
3936
+ cwd?: string;
3937
+ base?: string;
3938
+ maxFiles?: number;
3939
+ }): WorkflowImpactGateResult;
3940
+ declare function collectSyncDocuments(options: {
3941
+ file?: string;
3997
3942
  dir?: string;
3998
- json?: boolean;
3999
- verbose?: boolean;
3943
+ prefix?: string;
3944
+ recursive?: boolean;
3945
+ }): SyncDocumentInput[];
3946
+ declare function collectSyncDocumentsInput(options: {
3947
+ file?: string;
3948
+ dir?: string;
3949
+ prefix?: string;
3950
+ recursive?: boolean;
3951
+ }): CollectedSyncDocuments;
3952
+ interface OnboardFolderOptions {
3953
+ dir: string;
3954
+ recursive?: boolean;
3955
+ mode?: OnboardFolderMode;
3956
+ prefix?: string;
3957
+ usageMode?: string;
3958
+ sourceKind?: string;
3959
+ sourceProvider?: string;
3960
+ sourceUri?: string;
3961
+ clientId?: string;
3962
+ snapshotAt?: string;
3963
+ deleteMissing?: boolean;
3964
+ reindex?: boolean;
3965
+ reindexKind?: ReindexKind;
3966
+ reindexMode?: ReindexMode;
4000
3967
  }
4001
- interface CollaborationHooksInstallOptions {
3968
+ declare function buildOnboardFolderManifest(options: OnboardFolderOptions): OnboardFolderManifest;
3969
+ declare function buildSyncDocumentsDryRun(documents: SyncDocumentInput[], options?: {
3970
+ deleteMissing?: boolean;
3971
+ reindex?: boolean;
3972
+ reindexKind?: ReindexKind;
3973
+ reindexMode?: ReindexMode;
3974
+ now?: Date;
3975
+ }): SyncDocumentsDryRunSummary;
3976
+ declare function buildAgenticWorkStatus(cwd?: string): AgenticWorkStatus;
3977
+ declare function buildAgenticTimeline(options?: {
3978
+ limit?: number;
3979
+ cwd?: string;
3980
+ }): AgenticTimeline;
3981
+
3982
+ type LocalSourceProvider = "local_folder";
3983
+ type LocalSourceFileKind = "DOC" | "BINARY" | "CODE" | "CONFIG" | "OTHER";
3984
+ type LocalSourceSkippedReason = "ignored" | "too_large" | "read_error";
3985
+ type LocalSourceReindexKind = "doc" | "code";
3986
+ type LocalSourceReindexMode = "incremental" | "full";
3987
+ interface LocalSourceFile {
3988
+ path: string;
3989
+ kind: LocalSourceFileKind;
3990
+ format: string | null;
3991
+ sizeBytes: number;
3992
+ modifiedAt: string;
3993
+ sha256: string;
3994
+ }
3995
+ interface LocalSourceSkippedFile {
3996
+ path: string;
3997
+ reason: LocalSourceSkippedReason;
3998
+ sizeBytes?: number;
3999
+ }
4000
+ interface LocalSourceSummary {
4001
+ totalFiles: number;
4002
+ totalBytes: number;
4003
+ byKind: Record<LocalSourceFileKind, number>;
4004
+ skipped: number;
4005
+ }
4006
+ interface LocalSourceSnapshot {
4007
+ version: "snipara.local_source_snapshot.v1";
4008
+ generatedAt: string;
4009
+ root: string;
4010
+ provider: LocalSourceProvider;
4011
+ revision: string;
4012
+ recursive: boolean;
4013
+ maxFiles: number;
4014
+ maxFileBytes: number;
4015
+ summary: LocalSourceSummary;
4016
+ files: LocalSourceFile[];
4017
+ skipped: {
4018
+ total: number;
4019
+ byReason: Record<LocalSourceSkippedReason, number>;
4020
+ samples: LocalSourceSkippedFile[];
4021
+ };
4022
+ warnings: string[];
4023
+ }
4024
+ interface LocalSourceSnapshotOptions {
4002
4025
  dir?: string;
4003
- dryRun?: boolean;
4026
+ recursive?: boolean;
4027
+ maxFiles?: number;
4028
+ maxFileBytes?: number;
4029
+ }
4030
+ interface LocalSourceComparison {
4031
+ added: string[];
4032
+ modified: string[];
4033
+ deleted: string[];
4034
+ unchanged: number;
4035
+ }
4036
+ interface LocalSourceStatusResult {
4037
+ root: string;
4038
+ snapshotPath: string;
4039
+ previous: LocalSourceSnapshot | null;
4040
+ current: LocalSourceSnapshot;
4041
+ comparison: LocalSourceComparison;
4042
+ }
4043
+ interface LocalSourceSyncOptions extends LocalSourceSnapshotOptions {
4044
+ prefix?: string;
4045
+ mode?: OnboardFolderMode;
4046
+ deleteMissing?: boolean;
4047
+ apply?: boolean;
4048
+ reindex?: boolean;
4049
+ reindexKind?: LocalSourceReindexKind;
4050
+ reindexMode?: LocalSourceReindexMode;
4051
+ includeGraph?: boolean;
4004
4052
  json?: boolean;
4005
4053
  }
4006
- interface CollaborationLocalLeaseRecord {
4054
+ interface LocalSourceSyncResult {
4055
+ root: string;
4056
+ snapshotPath: string;
4057
+ snapshot: LocalSourceSnapshot;
4058
+ comparison: LocalSourceComparison;
4059
+ documents: {
4060
+ onboarding: Pick<OnboardFolderManifest, "source" | "classification" | "summary" | "warnings">;
4061
+ dryRun: OnboardFolderManifest["dryRun"];
4062
+ };
4063
+ codeOverlay: {
4064
+ cachePath: string;
4065
+ summary: LocalCodeOverlaySummary;
4066
+ };
4067
+ apply: null | {
4068
+ sync: Record<string, unknown>;
4069
+ reindex?: Record<string, unknown>;
4070
+ };
4071
+ warnings: string[];
4072
+ }
4073
+ declare function getLocalSourceSnapshotPath(cwd?: string): string;
4074
+ declare function buildLocalSourceSnapshot(options?: LocalSourceSnapshotOptions): LocalSourceSnapshot;
4075
+ declare function writeLocalSourceSnapshot(snapshot: LocalSourceSnapshot): string;
4076
+ declare function readLocalSourceSnapshot(cwd?: string): LocalSourceSnapshot | null;
4077
+ declare function compareLocalSourceSnapshots(previous: LocalSourceSnapshot | null, current: LocalSourceSnapshot): LocalSourceComparison;
4078
+ declare function buildLocalSourceStatus(options?: LocalSourceSnapshotOptions): LocalSourceStatusResult;
4079
+ declare function buildLocalSourceSyncResult(options?: LocalSourceSyncOptions): Promise<LocalSourceSyncResult>;
4080
+
4081
+ interface LocalWorkerDeclaration {
4007
4082
  id: string;
4008
- mode: CollaborationLeaseMode;
4009
- status: CollaborationLeaseStatus;
4010
- resources: CollaborationResource[];
4011
- reason?: string;
4012
- claimedAt?: string;
4013
- expiresAt?: string | null;
4083
+ workerRole: string;
4084
+ endpointType: "local";
4085
+ provider: string;
4086
+ baseUrl: string;
4087
+ command?: string;
4088
+ model?: string;
4089
+ preferModel?: string;
4090
+ capabilities: string[];
4091
+ reasoning: "low" | "medium" | "high";
4092
+ writeScope: string[];
4093
+ createdAt: string;
4094
+ updatedAt: string;
4014
4095
  }
4015
- interface CollaborationLocalState {
4016
- schemaVersion: "snipara.collaboration.v1";
4096
+ interface LocalWorkersConfig {
4097
+ schemaVersion: "snipara.local_workers.v1";
4017
4098
  updatedAt: string;
4018
- workSessionId?: string;
4019
- sessionId?: string;
4020
- actorId?: string;
4021
- actorType?: CollaborationActorType;
4022
- actorLabel?: string;
4023
- client?: string;
4024
- repository?: string;
4025
- branch?: string;
4026
- worktree?: string;
4027
- task?: string;
4028
- files: string[];
4029
- resources: CollaborationResource[];
4030
- leases: CollaborationLocalLeaseRecord[];
4031
- lastGuard?: {
4032
- decision: CollaborationGuardDecision;
4033
- severity: string;
4034
- checkedAt: string;
4035
- action: string;
4036
- resources: CollaborationResource[];
4037
- conflictCount: number;
4038
- };
4099
+ defaultWorkerId: string;
4100
+ workers: LocalWorkerDeclaration[];
4039
4101
  }
4040
- interface ResolvedCollaborationContext {
4041
- rootDir: string;
4042
- config: RLMConfig;
4043
- actor: Required<Pick<CollaborationActorPayload, "actorId" | "actorType" | "actorLabel">> & {
4044
- sessionId?: string;
4045
- };
4046
- client: string;
4047
- branch?: string;
4048
- repository?: string;
4049
- worktree?: string;
4102
+ interface LocalWorkerRoutingDefaults {
4103
+ worker: LocalWorkerDeclaration;
4104
+ routeLocalWorkers: true;
4105
+ routingWorkerRole: string;
4106
+ routingLocalBaseUrl: string;
4107
+ routingLocalModel?: string;
4108
+ routingLocalPreferModel?: string;
4109
+ routingLocalProvider: string;
4110
+ routingPreferredEndpoints: string[];
4111
+ routingAllowedEndpoints: string[];
4112
+ plannerRetainsReasoning: true;
4050
4113
  }
4051
- declare function createEmptyCollaborationState(now?: Date): CollaborationLocalState;
4052
- declare function getCollaborationStatePath(rootDir?: string): string;
4053
- declare function loadCollaborationState(rootDir?: string): CollaborationLocalState;
4054
- declare function saveCollaborationState(state: CollaborationLocalState, rootDir?: string): void;
4055
- declare function buildCollaborationActor(options: Pick<CollaborationCommandOptions, "actor" | "actorId" | "actorType" | "sessionId" | "client">, config: RLMConfig): ResolvedCollaborationContext["actor"];
4056
- declare function normalizeCollaborationFiles(files: string[] | undefined): string[];
4057
- declare function parseCollaborationResources(values: string[] | undefined): CollaborationResource[];
4058
- declare function deriveLocalCollaborationResourcesFromFiles(files: string[] | undefined, rootDir?: string, maxFiles?: number): CollaborationResource[];
4059
- declare function buildCollaborationHooksInstallPlan(options?: CollaborationHooksInstallOptions): Record<string, unknown>;
4060
- declare function collaborationIdeStatusCommand(options: CollaborationCommandOptions): Promise<void>;
4061
- declare function buildCollaborationGuardActionCards(evaluation: CollaborationGuardEvaluation | undefined, context?: {
4062
- profile?: string;
4063
- enforced?: boolean;
4064
- ackReviewOnly?: boolean;
4065
- reviewOnlyAcknowledged?: boolean;
4066
- }): CollaborationGuardActionCard[];
4067
- interface HostedGuardPayload {
4068
- files: string[];
4069
- resources: CollaborationResource[];
4070
- fileCount: number;
4071
- resourceCount: number;
4072
- filesTruncated: boolean;
4073
- resourcesTruncated: boolean;
4114
+ interface LocalWorkerAddOptions {
4115
+ id?: string;
4116
+ role?: string;
4117
+ provider?: string;
4118
+ baseUrl?: string;
4119
+ model?: string;
4120
+ preferModel?: string;
4121
+ capabilities?: string[];
4122
+ writeScope?: string[];
4123
+ contextWindow?: number;
4124
+ reasoning?: "low" | "medium" | "high";
4125
+ default?: boolean;
4126
+ json?: boolean;
4127
+ transport?: "openai_http" | "cli";
4128
+ command?: string;
4129
+ }
4130
+ interface LocalWorkerStatusOptions {
4131
+ json?: boolean;
4132
+ }
4133
+ interface LocalWorkerListOptions {
4134
+ json?: boolean;
4135
+ }
4136
+ interface LocalWorkerRemoveOptions {
4137
+ id: string;
4138
+ json?: boolean;
4139
+ }
4140
+ interface LocalWorkerProbeOptions {
4141
+ baseUrl?: string;
4142
+ provider?: string;
4143
+ model?: string;
4144
+ preferModel?: string;
4145
+ role?: string;
4146
+ workerId?: string;
4147
+ capabilities?: string[];
4148
+ writeScope?: string[];
4149
+ reasoning?: "low" | "medium" | "high";
4150
+ contextWindow?: number;
4151
+ json?: boolean;
4152
+ }
4153
+ declare function workersLocalAddCommand(options: LocalWorkerAddOptions): void;
4154
+ declare function workersLocalStatusCommand(options?: LocalWorkerStatusOptions): void;
4155
+ declare function workersLocalListCommand(options?: LocalWorkerListOptions): void;
4156
+ declare function workersLocalRemoveCommand(options: LocalWorkerRemoveOptions): void;
4157
+ declare function workersLocalProbePrintCommand(options: LocalWorkerProbeOptions): void;
4158
+ declare function addLocalWorker(options: LocalWorkerAddOptions): {
4159
+ worker: LocalWorkerDeclaration;
4160
+ config: LocalWorkersConfig;
4161
+ workerConfigPath: string;
4162
+ policyPath: string;
4163
+ };
4164
+ declare function resolveLocalWorkerRoutingDefaults(options?: {
4165
+ workerId?: string;
4166
+ workerRole?: string;
4167
+ }): LocalWorkerRoutingDefaults | null;
4168
+ declare function readLocalWorkersConfig(): LocalWorkersConfig | null;
4169
+
4170
+ interface ControlledWorkerExecuteOptions {
4171
+ task: string;
4172
+ workerId?: string;
4173
+ workerRole?: string;
4174
+ endpointType?: "local" | "cloud" | "self_hosted" | "unknown";
4175
+ mode?: ControlledWorkerExecutionMode;
4176
+ command?: string;
4177
+ execute?: boolean;
4178
+ approvalReceipt?: string;
4179
+ outcomeReceipt?: string;
4180
+ writeScope?: string[];
4181
+ acceptance?: string[];
4182
+ proof?: string[];
4183
+ output?: string;
4184
+ projectId?: string;
4185
+ unifiedOutput?: string;
4186
+ dir?: string;
4187
+ json?: boolean;
4074
4188
  }
4075
- declare function buildHostedGuardPayload(files: string[], resources: CollaborationResource[]): HostedGuardPayload;
4076
- declare function compactHostedGuardResources(resources: CollaborationResource[]): CollaborationResource[];
4077
-
4078
- interface JournalCheckpointPayload {
4079
- action: string;
4080
- summary: string;
4081
- outcome?: string;
4082
- workflowId?: string;
4083
- phaseId?: string;
4084
- phaseTitle?: string;
4085
- branch?: string;
4086
- actor?: string;
4087
- next?: string;
4088
- attention?: string;
4089
- files?: string[];
4090
- cwd?: string;
4189
+ interface ControlledWorkerExecuteResult {
4190
+ executed: boolean;
4191
+ blocked: boolean;
4192
+ receiptPath: string;
4193
+ unifiedReceiptPath: string | null;
4194
+ receipt: ControlledWorkerExecutionReceipt;
4195
+ unifiedReceipt: UnifiedReceiptEnvelope<ControlledWorkerExecutionReceipt> | null;
4091
4196
  }
4092
- declare function buildJournalCheckpointEntry(payload: JournalCheckpointPayload): {
4093
- text: string;
4094
- tags: string[];
4095
- };
4197
+ declare function controlledWorkerExecuteCommand(options: ControlledWorkerExecuteOptions): ControlledWorkerExecuteResult;
4096
4198
 
4097
- type RuntimeEnvironment = Record<string, string | undefined>;
4098
- type ProviderKeySource = "environment" | "env-file";
4099
- type OrchestratorRecommendationLevel = "suggest" | "confirm" | "auto";
4100
- type OrchestratorRecommendationReason = "workflow_mode_orchestrate" | "production_validation_intent" | "proof_gate_intent" | "htask_or_swarm_intent" | "multi_agent_intent" | "parallel_worker_intent" | "changed_files_threshold" | "team_sync_collision" | "policy_auto_route";
4101
- interface OrchestratorRecommendation {
4102
- level: OrchestratorRecommendationLevel;
4103
- reasons: OrchestratorRecommendationReason[];
4104
- score: number;
4105
- orchestratorRequired: boolean;
4106
- policySource?: string;
4199
+ declare const MANIFEST_VERSION = "snipara.references.v1";
4200
+ type ReferenceStatus = "allowed" | "pending" | "denied" | "unsupported";
4201
+ interface ReferenceOccurrence {
4202
+ file: string;
4203
+ line: number;
4204
+ label?: string;
4107
4205
  }
4108
- interface OrchestratorRecommendationOptions {
4109
- changedFilesCount?: number;
4110
- hasActiveCollisions?: boolean;
4111
- policyAutoRoute?: boolean;
4112
- policySource?: string;
4113
- adaptiveRoutingDryRun?: boolean;
4206
+ interface ReferenceManifestItem {
4207
+ id: string;
4208
+ url: string;
4209
+ normalizedUrl: string;
4210
+ domain: string;
4211
+ status: ReferenceStatus;
4212
+ reason: string;
4213
+ discoveredAt: string;
4214
+ occurrences: ReferenceOccurrence[];
4215
+ latestSnapshotPath?: string;
4216
+ latestFetchStatus?: number;
4217
+ latestFetchAt?: string;
4218
+ latestContentHash?: string;
4219
+ latestError?: string;
4114
4220
  }
4115
- interface RuntimeDetectionReport {
4116
- cwd: string;
4117
- workspaceRoot: string | null;
4118
- companion: {
4119
- configured: boolean;
4120
- configPath: string;
4121
- };
4122
- runtime: {
4123
- cliAvailable: boolean;
4124
- command?: string;
4125
- legacyCommand?: boolean;
4126
- version?: string;
4127
- cliVersion?: string;
4128
- installedPackageVersion?: string;
4129
- versionMismatch?: boolean;
4130
- mcpConfigured: boolean;
4131
- mcpConfigPaths: string[];
4132
- };
4133
- orchestrator: {
4134
- cliAvailable: boolean;
4135
- command?: string;
4136
- version?: string;
4137
- source?: "path" | "workspace_venv";
4138
- workspacePackageVersion?: string;
4139
- versionMismatch?: boolean;
4140
- };
4141
- providerKeys: {
4142
- openai: boolean;
4143
- anthropic: boolean;
4144
- any: boolean;
4145
- sources: {
4146
- openai?: ProviderKeySource;
4147
- anthropic?: ProviderKeySource;
4148
- };
4149
- envFilesLoaded: string[];
4150
- };
4151
- docker: {
4152
- available: boolean;
4153
- };
4221
+ interface ReferenceManifest {
4222
+ version: typeof MANIFEST_VERSION;
4223
+ generatedAt: string;
4224
+ root: string;
4225
+ allowDomains: string[];
4226
+ denyDomains: string[];
4227
+ items: ReferenceManifestItem[];
4154
4228
  }
4155
- declare function detectRuntimeEnvironment(cwd?: string, env?: RuntimeEnvironment): RuntimeDetectionReport;
4156
- declare function shouldSuggestRuntimeForWorkflow(query: string, mode: WorkflowMode): boolean;
4157
- /**
4158
- * Recommend whether work should be routed to snipara-orchestrator.
4159
- *
4160
- * Scores intent signals from the query and workflow mode (orchestrate mode,
4161
- * production / proof / htask / multi-agent / parallel patterns) plus contextual
4162
- * signals (changed-file count, active Team Sync collisions, policy auto-route).
4163
- * The returned recommendation's level escalates with the accumulated score
4164
- * (suggest → confirm → auto).
4165
- *
4166
- * @returns A recommendation with its reasons, or `null` when no signal fires.
4167
- */
4168
- declare function getOrchestratorRecommendation(query: string, mode: WorkflowMode, options?: OrchestratorRecommendationOptions): OrchestratorRecommendation | null;
4169
- declare function formatOrchestratorRecommendationReason(reason: OrchestratorRecommendationReason): string;
4170
- declare function shouldSuggestOrchestratorForWorkflow(query: string, mode: WorkflowMode): boolean;
4229
+ interface ScanReferencesOptions {
4230
+ root?: string;
4231
+ output?: string;
4232
+ allowDomain?: string[];
4233
+ denyDomain?: string[];
4234
+ extensions?: string[];
4235
+ maxFiles?: number;
4236
+ json?: boolean;
4237
+ }
4238
+ interface IngestReferencesOptions {
4239
+ manifest?: string;
4240
+ outputDir?: string;
4241
+ allowDomain?: string[];
4242
+ ids?: string[];
4243
+ max?: number;
4244
+ timeoutMs?: number;
4245
+ maxBytes?: number;
4246
+ destinationPrefix?: string;
4247
+ upload?: boolean;
4248
+ reindex?: boolean;
4249
+ dryRun?: boolean;
4250
+ json?: boolean;
4251
+ }
4252
+ interface ScanSummary {
4253
+ manifest: ReferenceManifest;
4254
+ outputPath: string;
4255
+ scannedFiles: number;
4256
+ foundUrls: number;
4257
+ allowed: number;
4258
+ pending: number;
4259
+ denied: number;
4260
+ unsupported: number;
4261
+ }
4262
+ interface IngestSummary {
4263
+ manifestPath: string;
4264
+ selected: number;
4265
+ fetched: number;
4266
+ uploaded: number;
4267
+ failed: number;
4268
+ dryRun: boolean;
4269
+ snapshots: Array<{
4270
+ id: string;
4271
+ url: string;
4272
+ snapshotPath?: string;
4273
+ destinationPath?: string;
4274
+ status?: number;
4275
+ uploaded?: boolean;
4276
+ error?: string;
4277
+ }>;
4278
+ }
4279
+ declare function scanReferences(options?: ScanReferencesOptions): ScanSummary;
4280
+ declare function ingestReferences(options?: IngestReferencesOptions): Promise<IngestSummary>;
4281
+ declare function referencesScanCommand(options: ScanReferencesOptions): Promise<void>;
4282
+ declare function referencesIngestCommand(options: IngestReferencesOptions): Promise<void>;
4171
4283
 
4172
- declare const ORCHESTRATOR_HANDOFF_RELATIVE_PATH: string;
4173
- interface OrchestratorHandoffWorkflowPhase {
4174
- id: string;
4175
- title: string;
4176
- query: string;
4177
- status: string;
4178
- acceptance?: string;
4179
- files: string[];
4180
- gates: string[];
4181
- needsRuntime: boolean;
4284
+ declare const POLICY_LEDGER_SYNC_REPORT_VERSION: "snipara.workflow_policy_ledger_sync.v0";
4285
+ interface PolicyLedgerSyncSummary {
4286
+ total: number;
4287
+ pendingRequests: number;
4288
+ resolvedDecisions: number;
4289
+ applyReceipts: number;
4290
+ policyDrafts: number;
4182
4291
  }
4183
- interface OrchestratorHandoffRuntimeSandboxPhase {
4184
- phaseId: string;
4185
- title: string;
4186
- bootstrapQuery: string;
4187
- files: string[];
4188
- artifacts: string[];
4189
- contextPacks: string[];
4190
- sessionId: string | null;
4191
- environment: string | null;
4192
- profile: string | null;
4193
- hasCheckpoint: boolean;
4194
- checkpointSummary: string | null;
4195
- checkpointCapturedAt: string | null;
4292
+ interface PolicyLedgerSyncReport {
4293
+ version: typeof POLICY_LEDGER_SYNC_REPORT_VERSION;
4294
+ generatedAt: string;
4295
+ dryRun: boolean;
4296
+ summary: PolicyLedgerSyncSummary;
4297
+ artifacts: ProjectPolicyLedgerSyncArtifactInput[];
4298
+ hosted?: Record<string, unknown>;
4299
+ caveats: string[];
4196
4300
  }
4197
- interface AdaptiveWorkProfile {
4198
- taskType: string;
4199
- risk: string;
4200
- scope: string[];
4201
- contextBudget: string;
4202
- reasoningDepth: string;
4203
- evidenceRequirements?: string[];
4204
- preferredProfileStrengths?: string[];
4205
- notes?: string[];
4301
+ declare function buildPolicyLedgerSyncReport(options?: {
4302
+ cwd?: string;
4303
+ dryRun?: boolean;
4304
+ }): PolicyLedgerSyncReport;
4305
+ declare function workflowSyncPolicyLedgerCommand(options: {
4306
+ dryRun?: boolean;
4307
+ json?: boolean;
4308
+ }): Promise<void>;
4309
+ declare function collectPolicyLedgerSyncArtifacts(cwd?: string): ProjectPolicyLedgerSyncArtifactInput[];
4310
+
4311
+ type CacheStrategy = "exact" | "nearby" | "warm";
4312
+ interface QueryCacheScope {
4313
+ cwd?: string;
4314
+ projectId?: string;
4315
+ sessionId?: string;
4206
4316
  }
4207
- interface AdaptiveModelRequirements {
4208
- workerRole: string;
4209
- reasoning: string;
4210
- plannerRetainsReasoning: boolean;
4211
- speed: string;
4212
- cost: string;
4213
- contextBudget: string;
4214
- capabilities: string[];
4215
- forbiddenCapabilities: string[];
4216
- writeScope: string[];
4217
- structuredOutputRequired?: boolean;
4218
- preferredEndpointTypes?: string[];
4219
- allowedEndpointTypes?: string[];
4220
- catalogLimit?: number;
4221
- dailyBudgetCents?: number;
4222
- monthlyBudgetCents?: number;
4223
- fallback: "main_agent";
4317
+ interface QueryCacheLookup {
4318
+ query: string;
4319
+ maxTokens: number;
4224
4320
  }
4225
- interface AdaptiveRoutingCostEstimate {
4226
- currency: "USD";
4227
- confidence: "low" | "medium" | "high";
4321
+ interface QueryCacheHit {
4322
+ strategy: CacheStrategy;
4323
+ result: ContextQueryResult;
4324
+ sourceQuery: string;
4325
+ similarity?: number;
4228
4326
  }
4229
- interface AdaptiveRoutingCard {
4230
- mode: "dry_run";
4231
- workProfile: AdaptiveWorkProfile;
4232
- requirements: AdaptiveModelRequirements;
4233
- recommendedWorkerClass: string;
4234
- costEstimate: AdaptiveRoutingCostEstimate;
4235
- humanApprovalRequired: boolean;
4236
- fallback: "main_agent";
4237
- rejectedReasons?: Record<string, string[]>;
4238
- reasons: string[];
4239
- warnings: string[];
4327
+ interface WarmSnapshotResult {
4328
+ storedEntries: number;
4329
+ fileName?: string;
4240
4330
  }
4241
- interface AdaptiveRoutingGatewayStatus {
4242
- source: "hosted_mcp" | "local_orchestrator";
4243
- success: boolean;
4244
- resolutionStatus?: string;
4245
- candidateCount: number;
4246
- fallback?: string;
4247
- warnings: string[];
4331
+ declare class LocalQueryCache {
4332
+ private readonly scope;
4333
+ private readonly ttlMs;
4334
+ private readonly warmTtlMs;
4335
+ private readonly maxEntries;
4336
+ private readonly maxBytes;
4337
+ constructor(scope?: QueryCacheScope);
4338
+ lookup(options: QueryCacheLookup): QueryCacheHit | null;
4339
+ save(options: QueryCacheLookup, result: ContextQueryResult): void;
4340
+ storeWarmSnapshot(result: SessionMemoriesResult): WarmSnapshotResult;
4341
+ clear(): number;
4342
+ private loadIndex;
4343
+ private persistIndex;
4344
+ private pruneIndex;
4345
+ private readEntry;
4346
+ private findNearbyEntry;
4347
+ private lookupWarmSnapshot;
4248
4348
  }
4249
- interface AdaptiveRoutingRuntimeCatalog {
4250
- version?: string;
4251
- source?: string;
4252
- provider?: string;
4253
- baseUrl?: string;
4254
- models?: string[];
4255
- apiPaths?: Record<string, unknown>;
4256
- workerEndpoints?: Record<string, Record<string, unknown>>;
4257
- workerProfiles?: Record<string, Record<string, unknown>>;
4258
- candidates: Array<Record<string, unknown>>;
4349
+ declare function createLocalQueryCache(scope?: QueryCacheScope): LocalQueryCache;
4350
+
4351
+ declare const AUTOMATION_MANIFEST_RELATIVE_PATH = ".snipara/automations/manifest.json";
4352
+ type AutomationFileState = "create" | "update" | "unchanged" | "conflict";
4353
+ interface AutomationManifestFile {
4354
+ path: string;
4355
+ sha256: string;
4259
4356
  }
4260
- interface AdaptiveRoutingResolution {
4261
- status?: string;
4262
- selected?: Record<string, unknown>;
4263
- policyDecision?: Record<string, unknown>;
4264
- evaluatedCount?: number;
4265
- rejectedCount?: number;
4266
- fallback?: string;
4267
- reasons?: string[];
4268
- warnings?: string[];
4269
- rejectedReasons?: Record<string, string[]>;
4357
+ interface AutomationManifest {
4358
+ version: number;
4359
+ client: string;
4360
+ projectId?: string;
4361
+ apiUrl?: string;
4362
+ installedAt: string;
4363
+ files: AutomationManifestFile[];
4270
4364
  }
4271
- interface AdaptiveWorkRoutingRecommendation {
4272
- workProfile: AdaptiveWorkProfile;
4273
- requirements: AdaptiveModelRequirements;
4274
- routingCard: AdaptiveRoutingCard;
4275
- gateway?: AdaptiveRoutingGatewayStatus;
4276
- runtimeCatalog?: AdaptiveRoutingRuntimeCatalog;
4277
- resolution?: AdaptiveRoutingResolution;
4365
+ interface AutomationFilePlan {
4366
+ path: string;
4367
+ targetPath: string;
4368
+ state: AutomationFileState;
4369
+ reason: string;
4370
+ currentSha256?: string;
4371
+ previousSha256?: string;
4372
+ nextSha256: string;
4373
+ writeContent?: string;
4278
4374
  }
4279
- interface AdaptiveWorkRoutingOptions {
4280
- query: string;
4281
- mode?: string;
4282
- changedFiles?: string[];
4283
- preferredEndpointTypes?: string[];
4284
- allowedEndpointTypes?: string[];
4285
- workerRole?: string;
4286
- plannerRetainsReasoning?: boolean;
4287
- preferredProfileStrengths?: string[];
4288
- structuredOutputRequired?: boolean;
4289
- catalogLimit?: number;
4290
- dailyBudgetCents?: number;
4291
- monthlyBudgetCents?: number;
4375
+ interface AutomationInstallResult {
4376
+ manifest: AutomationManifest;
4377
+ plan: AutomationFilePlan[];
4378
+ written: number;
4379
+ unchanged: number;
4380
+ dryRun: boolean;
4292
4381
  }
4293
- interface OrchestratorHandoffArtifact {
4294
- schemaVersion: "snipara.orchestrator.handoff.v1";
4295
- source: {
4296
- client: "snipara-companion";
4297
- command: string;
4298
- generatedAt: string;
4299
- };
4300
- workflow: {
4301
- mode: string;
4302
- workflowId: string | null;
4303
- currentPhaseId: string | null;
4304
- phases: OrchestratorHandoffWorkflowPhase[];
4305
- };
4306
- runtime: {
4307
- sandbox: {
4308
- provider: "snipara-sandbox";
4309
- phases: OrchestratorHandoffRuntimeSandboxPhase[];
4310
- } | null;
4311
- };
4312
- routing: {
4313
- level: OrchestratorRecommendation["level"];
4314
- reasons: OrchestratorRecommendation["reasons"];
4315
- policySource: string | null;
4316
- workProfile?: AdaptiveWorkProfile;
4317
- requirements?: AdaptiveModelRequirements;
4318
- routingCard?: AdaptiveRoutingCard;
4319
- gateway?: AdaptiveRoutingGatewayStatus;
4320
- runtimeCatalog?: AdaptiveRoutingRuntimeCatalog;
4321
- resolution?: AdaptiveRoutingResolution;
4322
- };
4323
- task: {
4324
- title: string;
4325
- query: string;
4326
- summary: string;
4327
- };
4328
- repo: {
4329
- root: string;
4330
- branch: string | null;
4331
- headSha: string | null;
4332
- changedFiles: string[];
4333
- };
4334
- coordination: {
4335
- swarmId: string | null;
4336
- claimScope: {
4337
- files: string[];
4338
- symbols: string[];
4339
- };
4340
- htask: {
4341
- featureTitle: string | null;
4342
- workstreams: string[];
4343
- };
4344
- };
4345
- validation: {
4346
- requiresProofGate: boolean;
4347
- requiresDriftCheck: boolean;
4348
- liveChecks: string[];
4349
- requiredEvidence: Array<{
4350
- type: string;
4351
- description: string;
4352
- }>;
4353
- };
4354
- memory: {
4355
- decisionIds: string[];
4356
- contextRefs: string[];
4357
- resumeSummary: string | null;
4358
- };
4382
+ interface AutomationStatusResult {
4383
+ manifest: AutomationManifest | null;
4384
+ files: Array<{
4385
+ path: string;
4386
+ targetPath: string;
4387
+ state: "up-to-date" | "modified" | "missing";
4388
+ expectedSha256: string;
4389
+ currentSha256?: string;
4390
+ }>;
4359
4391
  }
4360
- interface OrchestratorHandoffOptions {
4361
- sourceCommand: string;
4362
- recommendation: OrchestratorRecommendation;
4363
- query: string;
4364
- summary: string;
4365
- title?: string;
4366
- mode?: string;
4367
- rootDir?: string;
4368
- changedFiles?: string[];
4369
- contextRefs?: string[];
4370
- decisionIds?: string[];
4371
- resumeSummary?: string;
4372
- featureTitle?: string;
4373
- workstreams?: string[];
4374
- adaptiveRouting?: AdaptiveWorkRoutingRecommendation | null;
4392
+ declare class AutomationInstallConflictError extends Error {
4393
+ conflicts: AutomationFilePlan[];
4394
+ constructor(conflicts: AutomationFilePlan[]);
4375
4395
  }
4376
- interface WrittenOrchestratorHandoff {
4377
- handoff: OrchestratorHandoffArtifact;
4378
- path: string;
4379
- relativePath: string;
4380
- command: string;
4396
+ declare class AutomationUnsupportedHookBundleError extends Error {
4397
+ client: string;
4398
+ files: string[];
4399
+ constructor(client: string, files: string[]);
4381
4400
  }
4382
- declare function buildOrchestratorHandoff(options: OrchestratorHandoffOptions): OrchestratorHandoffArtifact;
4383
- declare function buildAdaptiveWorkRoutingRecommendation(options: AdaptiveWorkRoutingOptions): AdaptiveWorkRoutingRecommendation;
4384
- declare function writeOrchestratorHandoff(options: OrchestratorHandoffOptions): WrittenOrchestratorHandoff;
4401
+ declare function getAutomationManifestPath(projectDir?: string): string;
4402
+ declare function loadAutomationManifest(projectDir?: string): AutomationManifest | null;
4403
+ declare function buildAutomationInstallPlan(args: {
4404
+ projectDir: string;
4405
+ bundle: AutomationConfigBundle;
4406
+ manifest?: AutomationManifest | null;
4407
+ force?: boolean;
4408
+ }): AutomationFilePlan[];
4409
+ declare function installAutomationBundle(args: {
4410
+ client: string;
4411
+ projectDir?: string;
4412
+ bundle?: AutomationConfigBundle;
4413
+ force?: boolean;
4414
+ dryRun?: boolean;
4415
+ }): Promise<AutomationInstallResult>;
4416
+ declare function getAutomationStatus(projectDir?: string): AutomationStatusResult;
4385
4417
 
4386
4418
  export { AUTOMATION_MANIFEST_RELATIVE_PATH, AutomationInstallConflictError, AutomationUnsupportedHookBundleError, CODING_INTELLIGENCE_LEDGER_VERSION, COLLABORATION_STATE_RELATIVE_PATH, ENGINEERING_LEAD_EXECUTION_RECEIPT_STAGES, ENGINEERING_LEAD_EXECUTION_RECEIPT_STATUSES, ENGINEERING_LEAD_POSTURES, ENGINEERING_LEAD_PROOF_VERIFICATION_SOURCES, ENGINEERING_LEAD_PROOF_VERIFICATION_STATUSES, ENGINEERING_LEAD_ROUTING_MODES, ENGINEERING_LEAD_STATUSES, ENGINEERING_LEAD_SUPERVISION_STATUSES, ENGINEERING_LEAD_WORKER_ROLES, ENGINEERING_LEAD_WORK_PACKAGE_STATUSES, ORCHESTRATOR_HANDOFF_RELATIVE_PATH, POLICY_LEDGER_SYNC_REPORT_VERSION, PRODUCER_LOOP_ARTIFACT_VERSION, PRODUCER_LOOP_RELATIVE_DIR, PRODUCER_LOOP_REPORT_VERSION, TEAM_SYNC_STATE_RELATIVE_PATH, WHY_OUTCOME_CAPTURE_VERSION, WORKFLOW_PLANS_RELATIVE_DIR, WORKFLOW_STATE_RELATIVE_PATH, addLocalWorker, agentReadinessAuditCommand, appendActivityEvent, archiveInactiveTeamSyncWork, attachLocalContextPackReceipts, autoArchiveTeamSyncState, buildAdaptiveWorkRoutingRecommendation, buildAgentReadinessAuditReport, buildAgenticHandoffMarkdown, buildAgenticTimeline, buildAgenticWorkStatus, buildAutomationInstallPlan, buildCanonicalEvent, buildCodeHooksInstallPlan, buildCodePromotionResult, buildCodeStatusResult, buildCodeSyncResult, buildCodingIntelligenceLedger, buildCollaborationActor, buildCollaborationGuardActionCards, buildCollaborationHooksInstallPlan, buildCompanionEngineeringLeadPlanReport, buildContextPackStats, buildEvalCaseArtifact, buildGeneratedWorkflowPlanDocument, buildHostedCodeOverlayUploadPayload, buildHostedGuardPayload, buildJournalCheckpointEntry, buildLocalCallersResult, buildLocalCodeOverlay, buildLocalContextPackReceipt, buildLocalContextPackReceipts, buildLocalImpactResult, buildLocalImportsResult, buildLocalNeighborsResult, buildLocalProjectRealityCheck, buildLocalShortestPathResult, buildLocalSourceSnapshot, buildLocalSourceStatus, buildLocalSourceSyncResult, buildMemoryAudit, buildOnboardFolderManifest, buildOrchestratorHandoff, buildPolicyLedgerSyncReport, buildProducerLoopReport, buildProjectIntelligenceBrief, buildProjectIntelligenceRun, buildProjectJudgmentCard, buildSessionBootstrapBrief, buildSessionBootstrapQuality, buildSessionSnapshot, buildSyncDocumentsDryRun, buildTeamSyncHandoffRecord, buildTeamSyncStartWorkRecord, buildTeamSyncSummary, buildToolCallPayload, buildToolResultPayload, buildVerificationPlan, buildWhyOutcomeCaptureReport, buildWorkflowImpactGate, buildWorkflowPhaseCommitSummary, buildWorkflowPlanScaffold, categoryFromGuardTag, classifyToolResult, cleanContextPacks, codingLedgerExportCommand, collaborationIdeStatusCommand, collectAgentReadinessLocalSignals, collectPolicyLedgerSyncArtifacts, collectSyncDocuments, collectSyncDocumentsInput, compactHostedGuardResources, compareLocalSourceSnapshots, completeTeamSyncStateFromEvidence, completeTeamSyncWorkFromEvidence, contextPackCleanCommand, contextPackPackCommand, contextPackRetrieveCommand, contextPackStatsCommand, controlledWorkerExecuteCommand, createClient, createEmptyCollaborationState, createEmptyTeamSyncState, createLocalQueryCache, deriveLocalCollaborationResourcesFromFiles, detectReleaseSurfacesFromFiles, detectRuntimeEnvironment, evalExportCommand, evalRunCommand, evaluateProjectPolicyGates, extractCommandFromToolInput, extractFilesFromToolInput, formatAgentReadinessAuditReport, formatCompanionEngineeringLeadPlanReport, formatOrchestratorRecommendationReason, formatPolicyGateDecision, formatProjectJudgmentCard, formatStuckGuardDecision, getAutomationManifestPath, getAutomationStatus, getCollaborationStatePath, getConfigPath, getContextPackStoragePaths, getLocalCodeOverlayCachePath, getLocalCodePromotionStatePath, getLocalSourceSnapshotPath, getOrchestratorRecommendation, getPlanStepDisplayTitle, getStagedFiles, getStuckGuardInjection, getTeamSyncStatePath, ingestReferences, installAutomationBundle, leadPlanCommand, listProjectsForApiKey, loadAutomationManifest, loadCollaborationState, loadConfig, loadTeamSyncState, memoryAuditCommand, memoryCleanCandidatesCommand, memoryCompactCommand, memoryHealthCommand, memoryLocalCommand, memoryReviewsCommand, normalizeCollaborationFiles, normalizeGuardTag, normalizeWorkflowPlanInput, outcomeCapturePreviewCommand, packContext, parseCollaborationResources, projectIntelligenceBriefCommand, projectIntelligenceRunCommand, readActivityTimeline, readLocalCodeOverlayCache, readLocalCodePromotionState, readLocalSourceSnapshot, readLocalWorkersConfig, readSessionSnapshot, realityCheckCommand, referencesIngestCommand, referencesScanCommand, resolveAutoWorkflowMode, resolveContextPackRecord, resolveFullWorkflowTokenBudget, resolveLocalWorkerRoutingDefaults, resolveQueryFromToolInput, retrieveContextPack, runMemoryGuardCheck, saveCollaborationState, saveConfig, saveTeamSyncState, scanReferences, shouldSuggestOrchestratorForWorkflow, shouldSuggestRuntimeForWorkflow, summarizeLocalCodeOverlay, teamSyncSweepCommand, validatePlanResult, verifyCommand, workersLocalAddCommand, workersLocalListCommand, workersLocalProbePrintCommand, workersLocalRemoveCommand, workersLocalStatusCommand, workflowSyncPolicyLedgerCommand, writeLocalCodeOverlayCache, writeLocalCodePromotionState, writeLocalSourceSnapshot, writeOrchestratorHandoff, writeProducerLoopArtifact, writeSessionSnapshot };