@agentdeploymentco/bishop 0.8.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.js +4 -4
- package/dist/harness/claude-marketplaces.js +1 -0
- package/dist/harness/claude-settings.js +1 -1
- package/dist/harness/claude.js +8 -8
- package/dist/harness/codex-project.js +2 -2
- package/dist/harness/layers.js +1 -1
- package/dist/teams/create.js +2 -2
- package/dist/teams/server.js +1 -1
- package/package.json +4 -4
package/dist/config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{mkdir as
|
|
2
|
-
`)}async function
|
|
3
|
-
${J(r.error)}`,
|
|
4
|
-
`,"utf8"),
|
|
1
|
+
import{mkdir as y,readFile as v,writeFile as O}from"node:fs/promises";import{dirname as j,join as $}from"node:path";import{z as t}from"zod";import{BishopError as l}from"./errors.js";const E=".bishop",R="config.json",I=t.strictObject({id:t.string().optional(),name:t.string().min(1),displayName:t.string().optional(),description:t.string().optional()}),N=["low","medium","high"],K="high",h=t.string().transform(e=>e.trim().toLowerCase()).pipe(t.enum(N)),S=t.strictObject({workspace:t.string().optional(),app:I.optional(),verbosity:h.optional(),allow:t.array(t.string().min(1)).optional(),maxBotTurns:t.number().int().nonnegative().optional()}),A=t.strictObject({allow:t.array(t.string().min(1)).optional(),pollSeconds:t.number().int().positive().optional(),labelPrefix:t.string().trim().min(1).optional(),markRead:t.boolean().optional(),internalDomains:t.array(t.string().trim().toLowerCase().regex(/^[^\s@]+\.[^\s@]+$/,"must be a domain like example.com")).optional()}),C=t.strictObject({cert:t.string().trim().min(1),key:t.string().trim().min(1)}),_=t.strictObject({id:t.string().optional(),name:t.string().min(1),displayName:t.string().optional(),description:t.string().optional()}),F=t.strictObject({app:_.optional(),allow:t.array(t.string().min(1)).optional(),verbosity:h.optional(),port:t.number().int().min(1).max(65535).optional(),host:t.string().trim().min(1).optional(),tls:C.optional(),healthPath:t.string().trim().refine(e=>{try{return new URL(e,"http://localhost").pathname===e}catch{return!1}},"must be a plain path starting with /, like /healthz").optional()}),p=["claude","codex"],T=t.union([t.literal(!1),t.strictObject({idleMinutes:t.number().positive().max(10080).optional(),max:t.number().int().positive().optional()})]),L=t.strictObject({model:t.string().trim().min(1).optional(),effort:t.string().trim().min(1).optional(),options:t.record(t.string(),t.unknown()).optional(),keepAlive:T.optional()}),z=t.strictObject({harness:t.enum(p).optional(),model:t.string().trim().min(1).optional(),effort:t.string().trim().min(1).optional(),harnesses:t.partialRecord(t.enum(p),L,{error:()=>`not a harness Bishop runs; supported: ${p.join(", ")}`}).superRefine((e,n)=>{e.codex?.keepAlive!==void 0&&n.addIssue({code:"custom",path:["codex","keepAlive"],message:"only the claude harness keeps an agent running between turns"})}).optional(),worktrees:t.boolean().optional(),projectSettings:t.boolean().optional(),sandbox:t.union([t.boolean(),t.strictObject({profile:t.string().trim().min(1).optional()})]).optional(),options:t.record(t.string(),t.unknown()).optional()}),B=t.strictObject({maxAgeDays:t.number().int().positive().optional()}),U=t.strictObject({maxMb:t.number().positive().optional()}),D=["all","external"],P=["reject","approve"],b=t.strictObject({scope:t.enum(D).optional(),onError:t.enum(P).optional()});function V(e){let n;try{n=new URL(e)}catch{return!1}return n.protocol==="https:"?!0:n.protocol!=="http:"?!1:n.hostname==="localhost"||n.hostname==="[::1]"||/^127(\.\d{1,3}){3}$/.test(n.hostname)}const G=t.strictObject({command:t.array(t.string().min(1)).min(1).optional(),url:t.string().trim().refine(V,"must be an https URL, or http on loopback").optional(),inbound:b.optional(),outbound:b.optional(),timeoutSeconds:t.number().positive().max(300).optional(),env:t.array(t.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,"must be an environment variable name")).optional()}).superRefine((e,n)=>{e.command&&e.url?n.addIssue({code:"custom",message:"names both command and url; pick one"}):!e.command&&!e.url&&n.addIssue({code:"custom",message:"needs a command or a url"}),e.url&&e.env&&n.addIssue({code:"custom",path:["env"],message:"is only for a command reviewer"}),!e.inbound&&!e.outbound&&n.addIssue({code:"custom",message:"reviews nothing without inbound or outbound"})}),H=t.strictObject({slack:S.optional(),gmail:A.optional(),teams:F.optional(),agent:z.optional(),files:U.optional(),gc:B.optional(),review:G.optional()}).superRefine((e,n)=>{e.review&&!e.agent?.sandbox&&n.addIssue({code:"custom",path:["review"],message:"needs agent.sandbox on"})});class m extends l{path;constructor(n,o){super(n,"ConfigError"),this.path=o}}function q(e,n={}){const o=e.agent,i=o?.harness??"claude",r=n.harness??i,s=o?.harnesses?.[r],{keepAlive:x,...k}=s??{},a=s&&Object.keys(k).length>0?s:void 0,c=[];o?.options&&(a&&r===i?c.push({kind:"options-replaced",harness:r}):!a&&r!==i&&c.push({kind:"options-foreign",harness:r,configured:i}));const u=n.model??a?.model??o?.model,d=n.effort??a?.effort??o?.effort,g=a?a.options:o?.options,f=r==="claude"?x:void 0;return{harness:r,...u?{model:u}:{},...d?{effort:d}:{},...g?{options:g}:{},...f!==void 0?{keepAlive:f}:{},warnings:c}}function Q(e){const n=e.agent?.sandbox;if(n)return n===!0||!n.profile?{}:{profile:n.profile}}function X(e){return n=>{const o=n.trim();if(!o)throw new l(`${e} needs a value`);return o}}function tt(e){return n=>{const o=Number(n.trim());if(!Number.isInteger(o)||o<=0)throw new l(`${e} needs a positive whole number, got "${n}"`);return o}}function nt(e){const n=e.trim();if(p.includes(n))return n;throw new l(`unknown harness "${e}"; supported: ${p.join(", ")}`)}function w(e=process.cwd()){return $(e,E,R)}function J(e){return e.issues.flatMap(n=>{if(n.code==="unrecognized_keys"&&n.keys.length>0){const o=n.message.startsWith("Unrecognized key")?"unrecognized key":n.message;return n.keys.map(i=>`${[...n.path,i].join(".")}: ${o}`)}return[`${n.path.length>0?n.path.join("."):"(root)"}: ${n.message}`]}).join(`
|
|
2
|
+
`)}async function et(e=process.cwd()){const n=w(e);let o;try{o=await v(n,"utf8")}catch(s){if(s.code==="ENOENT")return{};throw new m(`Couldn't read ${n}: ${s.message}`,n)}let i;try{i=JSON.parse(o)}catch(s){throw new m(`${n} isn't valid JSON: ${s.message}`,n)}const r=H.safeParse(i);if(!r.success)throw new m(`${n} has invalid values:
|
|
3
|
+
${J(r.error)}`,n);return r.data}async function ot(e,n=process.cwd()){const o=w(n);return await y(j(o),{recursive:!0}),await O(o,`${JSON.stringify(e,null,2)}
|
|
4
|
+
`,"utf8"),o}function rt(e){return e.displayName?.trim()||e.name}export{E as CONFIG_DIR,R as CONFIG_FILE,m as ConfigError,H as ConfigSchema,K as DEFAULT_VERBOSITY,p as HARNESSES,P as REVIEW_ON_ERROR,D as REVIEW_SCOPES,N as VERBOSITY,w as configPath,rt as displayNameOf,et as loadConfig,X as nonEmptyFlag,nt as parseHarnessName,tt as positiveIntFlag,q as resolveAgent,Q as sandboxConfig,ot as writeConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFile as L}from"node:fs/promises";import{createRequire as R}from"node:module";import{homedir as x}from"node:os";import{isAbsolute as S,join as w,resolve as g}from"node:path";import{exec as O}from"../exec.js";import{log as k}from"../log.js";import{repoRoot as M}from"../worktrees.js";import{isPlainObject as d,PLUGIN_INSTALL_TIMEOUT_MS as I,untilAborted as U}from"./layers.js";const C=["extraKnownMarketplaces","additionalMarketplaces"],$=new Set(["directory","file","settings"]),D=3600*1e3;function E(t){return C.flatMap(n=>{const e=t[n];return d(e)?Object.entries(e).filter(a=>d(a[1])):[]})}async function B(t,n,e=M){if(!E(t).some(([,u])=>y(u)!==void 0))return t;const a=await e(n)??n;let i=t;for(const u of C){const r=t[u];if(!d(r))continue;let s=!1;const f=Object.fromEntries(Object.entries(r).map(([l,o])=>{const p=y(o);if(p===void 0)return[l,o];s=!0;const{source:h}=o;return[l,{...o,source:{...h,path:g(a,p)}}]}));s&&(i={...i,[u]:f})}return i}function y(t){if(!d(t)||!d(t.source))return;const{source:n,path:e}=t.source;if(!(n!=="directory"&&n!=="file"))return typeof e=="string"&&e&&!S(e)?e:void 0}function j(t){if(!d(t))return[];const n=E(t).filter(([,e])=>e.autoUpdate===!0).filter(([,e])=>d(e.source)&&!$.has(String(e.source.source))).map(([e])=>e);return[...new Set(n)]}function P(t,n,e=x()){return t.CLAUDE_CODE_PLUGIN_CACHE_DIR?g(n,t.CLAUDE_CODE_PLUGIN_CACHE_DIR):w(g(n,t.CLAUDE_CONFIG_DIR||w(e,".claude")),"plugins")}async function v(t){try{const n=JSON.parse(await L(w(t,"known_marketplaces.json"),"utf8"));return new Set(d(n)?Object.keys(n):[])}catch{return new Set}}function J(){try{const t=R(import.meta.resolve("@anthropic-ai/claude-agent-sdk")),n=`@anthropic-ai/claude-agent-sdk-${process.platform}-${process.arch}`,e=process.platform==="win32"?"claude.exe":"claude",a=process.platform==="linux"?process.report?.getReport():void 0,u=a!==void 0&&a.header?.glibcVersionRuntime===void 0?[`${n}-musl`,n]:[n,`${n}-musl`];for(const r of u)try{return t.resolve(`${r}/${e}`)}catch{}}catch{}}function Y(t){return(n,e)=>O(t,n,{cwd:e.cwd,env:e.env,signal:e.signal})}function z(t=D,n=I,e=Date.now){const a=new Map,i=new Map,u=async(r,s,f)=>{const l={...r.context,marketplace:s},o=await r.run(["plugin","marketplace","update","--",s],{cwd:r.cwd,env:r.env,signal:f});if(o.code===0)k.info(l,"refreshed a plugin marketplace");else{const p=o.output.trim(),c=[f.aborted?"timed out":o.signal?`killed by ${o.signal}`:o.code===null?"couldn't start Claude Code":void 0,p].filter(Boolean).join(": ")||`exited with ${o.code}`;k.warn({...l,error:c},"couldn't refresh a plugin marketplace; this thread gets the copy already fetched")}};return async r=>{const s=j(r.settings);if(s.length===0)return;const f=P(r.env,r.cwd),l=c=>`${f}\0${c}`,o=await v(f),p=AbortSignal.timeout(n);for(const c of s){const m=l(c);if(i.has(m))continue;const _=a.get(m);if(_!==void 0&&e()-_<t||(a.set(m,e()),!o.has(c)))continue;const b=u(r,c,p).catch(A=>k.warn({...r.context,marketplace:c,err:A},"couldn't refresh a plugin marketplace; this thread gets the copy already fetched")).finally(()=>i.delete(m));i.set(m,b)}const h=s.flatMap(c=>i.get(l(c))??[]);await U(Promise.all(h),r.signal)}}export{D as MARKETPLACE_REFRESH_INTERVAL_MS,B as anchorLocalMarketplaces,j as autoUpdated,J as bundledClaude,Y as directClaude,z as marketplaceRefresher,P as pluginsRoot};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{realpath as d,stat as p}from"node:fs/promises";import{join as
|
|
1
|
+
import{realpath as d,stat as p}from"node:fs/promises";import{join as l}from"node:path";import{resolveSettings as m}from"@anthropic-ai/claude-agent-sdk";import{log as s}from"../log.js";import{sandboxReadable as g}from"../sandbox.js";import{anchorLocalMarketplaces as h}from"./claude-marketplaces.js";import{isPlainObject as u,PLUGIN_INSTALL_TIMEOUT_MS as w,unionLists as S}from"./layers.js";const j=1e3,y=l(".claude","settings.json");async function E(e,n){const r=l(e,y),i=await p(r).catch(()=>{});if(i)try{const t=await d(r);if(!i.isFile()||n&&!g(n,t)){s.warn({path:r,resolved:t},"the agent's settings file isn't a file the agent could read itself; passing nothing from it");return}const o=(await m({cwd:e,settingSources:["project"]})).sources.find(f=>f.source==="project");if(o)return await h(o.settings,e);s.warn({path:r},"the agent's settings file isn't valid Claude settings, so Claude skips it and Bishop passes nothing from it")}catch(t){s.warn({path:r,err:t},"couldn't read the agent's settings file; passing nothing from it")}}function c(e,n){if(n===void 0)return e;if(Array.isArray(e)&&Array.isArray(n))return S(e,n);if(u(e)&&u(n)){const r=new Set([...Object.keys(e),...Object.keys(n)]),i=(t,a)=>Object.hasOwn(t,a)?t[a]:void 0;return Object.fromEntries([...r].map(t=>[t,c(i(e,t),i(n,t))]))}return n}function M(...e){return e.reduce((n,r)=>c(n,r),{})}function C(e,n=w,r=Date.now){let i;return t=>{if(!(t.type!=="system"||t.subtype!=="plugin_install"))switch(t.status){case"started":i=r();return;case"installed":s.info({...e,marketplace:t.name},"installed plugins from a marketplace");return;case"failed":s.warn({...e,marketplace:t.name,error:t.error},"plugins from a marketplace failed to install");return;case"completed":{if(i===void 0||r()-i<n-j)return;s.warn({...e,timeoutMs:n},"plugin install hit its time limit; this turn runs without whatever had not finished");return}}}}export{y as SETTINGS_FILE,M as mergeSettings,C as pluginInstallWatcher,E as readAgentSettings};
|
package/dist/harness/claude.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{spawn as
|
|
2
|
-
`)[0]??"";return i.length>40?`${i.slice(0,37)}...`:i}}function
|
|
3
|
-
`)[0]??"";return s.length>48?`${s.slice(0,45)}...`:s}}}function
|
|
4
|
-
`)}function
|
|
1
|
+
import{spawn as W}from"node:child_process";import{existsSync as M,mkdirSync as H}from"node:fs";import{mkdir as Y}from"node:fs/promises";import{homedir as O}from"node:os";import{join as C,resolve as v}from"node:path";import{query as L}from"@anthropic-ai/claude-agent-sdk";import{log as f}from"../log.js";import{executableDir as V,nonoCommand as z}from"../sandbox.js";import{SERVER_NAME as A}from"../tools/server.js";import{isolates as _,repoRoot as J,WORKTREE_DIR as Q,worktreePath as X}from"../worktrees.js";import{bundledClaude as Z,directClaude as N,marketplaceRefresher as q}from"./claude-marketplaces.js";import{bishopServer as ee,buildAgentOptions as te,CONTROLLED_KEYS as ne,SETTINGS_ONLY_KEYS as oe}from"./claude-options.js";import{claudeProcesses as re,DEFAULT_KEEP_ALIVE as ie}from"./claude-processes.js";import{pluginInstallWatcher as se,readAgentSettings as ae}from"./claude-settings.js";import{ignoredKeys as P,shadowedKeys as de}from"./layers.js";import{buildPrompt as le,NO_OUTPUT as ce,principalInstructions as ue}from"./principal.js";const fe=new Set(["Agent","Task"]),pe=2e3;function he(t){if(!t||typeof t!="object")return;const{name:n,description:o}=t;for(const r of[n,o]){if(typeof r!="string"||!r.trim())continue;const i=r.trim().split(`
|
|
2
|
+
`)[0]??"";return i.length>40?`${i.slice(0,37)}...`:i}}function me(){const t=new Map,n=new Map,o=(r,i,a)=>{if(r.set(i,a),r.size>pe){const s=r.keys().next().value;s!==void 0&&r.delete(s)}};return function*(i){switch(i.type){case"system":i.subtype==="init"&&(yield{type:"session",sessionId:i.session_id,...i.model?{model:i.model}:{}});return;case"assistant":{const a=i.parent_tool_use_id||null,s=a===null?void 0:t.get(a)??"Subagent";for(const d of i.message.content)if(d.type==="text"&&d.text.trim())s||(yield{type:"text",text:d.text});else if(d.type==="tool_use"){const m=fe.has(d.name)?he(d.input):void 0;m&&o(t,d.id,m),s&&o(n,d.id,s);const g=m??ge(d.input);yield{type:"tool",name:d.name,...g?{detail:g}:{},...s?{agent:s}:{}}}else d.type==="thinking"&&!s&&(yield{type:"thinking"});return}case"tool_use_summary":{const a=i.preceding_tool_use_ids.map(s=>n.get(s)).find(s=>s!==void 0);yield{type:"tool_summary",summary:i.summary,...a?{agent:a}:{}};return}case"result":i.subtype==="success"?yield{type:"done",text:i.result,usage:{turns:i.num_turns,costUsd:i.total_cost_usd}}:yield{type:"error",kind:i.subtype,message:we(i.subtype)};return;default:return}}}function ge(t){if(!t||typeof t!="object")return;const n=t,o=n.file_path??n.notebook_path??n.path;if(typeof o=="string"&&o)return o.split("/").pop()??o;const r=n.url;if(typeof r=="string"&&r)try{return new URL(r).hostname}catch{return r.slice(0,40)}for(const i of["pattern","query","description"]){const a=n[i];if(typeof a=="string"&&a.trim()){const s=a.trim().split(`
|
|
3
|
+
`)[0]??"";return s.length>48?`${s.slice(0,45)}...`:s}}}function ye(t){switch(t){case"none":return"existing claude login or cloud provider";case"/login managed key":return"key managed by claude login";default:return t}}function we(t){switch(t){case"error_max_turns":return"the agent hit its turn limit before finishing";case"error_max_budget_usd":return"the agent hit its cost limit before finishing";case"error_during_execution":return"the agent stopped on an error";default:return`the agent stopped: ${t}`}}const be=new Set(["Edit","Write","NotebookEdit"]);function ke(t,n){return["This directory is shared with other conversations that may be running at the same time.",`Before you edit, create, or delete any file here, call EnterWorktree with name "${n}"`,"so your changes land in a git worktree of your own. Load the tool with ToolSearch first if","it isn't available. If a worktree by that name already exists, enter it by path instead:",`${X(t,n)}.`,"","Once you are in the worktree, work normally. Relative paths resolve inside it, and you","stay in it for every later message in this thread. Commit what you finish on the","worktree's branch and say which branch it is, since that's how a person finds your work.","Don't call ExitWorktree."].join(`
|
|
4
|
+
`)}function xe(t){const n=v(t);return({toolName:o,cwd:r})=>{if(be.has(o)&&v(r)===n)return"This is the shared checkout, which other conversations are using. Call EnterWorktree with the name given in your instructions, then make this edit inside the worktree."}}const ve=["When background work you started finishes after your reply, you are woken to report on it, and what you say is posted to the conversation.","Report on each subagent as it finishes, the way you would to someone waiting on the work.","Some conversations show only the report you make once all your subagents have finished, so make that one stand on its own: everything the people there need from all of the work, not only the piece that just finished.",`When nothing from the work needs saying, answer ${ce} and nothing else.`].join(" ");function _e(t,n,o,r,i=!1){const a=_(t)?ke(r,o):void 0;return[ue(n),i?ve:void 0,a].filter(s=>!!s?.trim()).join(`
|
|
5
5
|
|
|
6
|
-
`)}function
|
|
7
|
-
${o}`:
|
|
8
|
-
${
|
|
6
|
+
`)}function Se(t,n){return{model:n?.model??t.model,effort:n?.effort??t.effort}}function Ee(t){return async n=>{const o=n,r=t({toolName:o.tool_name,cwd:o.cwd});return r?(f.info({tool:o.tool_name,cwd:o.cwd},"refusing an edit in the shared checkout"),{continue:!0,hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:r}}):{continue:!0}}}function Te(t,n=O()){const o=t.CLAUDE_CONFIG_DIR;return o?{allow:[o]}:{allow:[C(n,".claude")],allowFiles:[C(n,".claude.json")].filter(M)}}async function Ce(t){const n=await J(t);if(!n||v(n)===v(t))return[];const o=C(n,Q);return await Y(o,{recursive:!0}),[o]}const Ae=2048;function R(t,n){const o=n.text.trim();return o?`${t}
|
|
7
|
+
${o}`:t}function Re(t){return n=>R(n,t)}function U(t,n,o,r,i){const a=Te(o);for(const d of a.allow??[])H(d,{recursive:!0});const s=V(r);return z(t,{allow:[...a.allow??[],...n],read:s?[s]:[],...a.allowFiles?{allowFiles:a.allowFiles}:{}},r,i)}function Ie(t,n){return n?(o,r)=>{const i=U(n,[],r.env,t,o);return N(i.command)(i.args,r)}:N(t)}function je(t,n,o){return r=>{const i=U(t,n,r.env,r.command,r.args),a=W(i.command,i.args,{...r.cwd?{cwd:r.cwd}:{},env:r.env,stdio:["pipe","pipe","pipe"],signal:r.signal});return a.stderr.on("data",s=>{o.text=(o.text+s.toString()).slice(-Ae)}),a.on("exit",s=>{const d=o.text.trim();s&&d&&f.warn({code:s,stderr:d},"the sandboxed agent exited with an error")}),a}}function ze(t={}){const n=P(t.options,ne);n.length>0&&f.warn({ignored:n},"these agent.options are set by Bishop and cannot be overridden; ignoring them");const o=t.options?.mcpServers;o&&typeof o=="object"&&Object.hasOwn(o,A)&&f.warn({server:A},`agent.options.mcpServers names a server "${A}", which is Bishop's own; ignoring it`);const r=e=>Se(t,e),i=r(),a=de(t.options,i);a.length>0&&f.warn({shadowed:a},"agent.model and agent.effort override these agent.options");const s=P(t.options,oe);s.length>0&&f.warn({misplaced:s},"the harness reads these from agent.options.settings only and ignores them here");const d=t.worktrees,m=t.projectSettings!==!1;if(typeof t.options?.settings=="string"){const e=["auto memory is left to that file and the agent's own settings"];_(d)&&e.push("new worktrees branch from origin/<default-branch> rather than HEAD"),m&&e.push("the agent's .claude/settings.json gets only what headless Claude trusts of it, without its allow rules or plugins"),f.warn({settings:t.options.settings},`agent.options.settings names a file, so Bishop applies no settings defaults: ${e.join("; ")}`)}const g=(e,c,l,p,h)=>{const u=_(d)?xe(e.cwd):void 0,x=u?{PreToolUse:[{hooks:[Ee(u)]}]}:void 0,w=te({...t.options?{configOptions:t.options}:{},general:r(c),...t.apiKey?{apiKey:t.apiKey}:{},...x?{hooks:x,worktrees:!0}:{},...p?{agentSettings:p}:{},...h?{installPlugins:h}:{},controlled:e});return l?{...w,spawnClaudeCodeProcess:l}:w},$=m&&typeof t.options?.settings!="string",I=(e,c)=>$?ae(e,c):Promise.resolve(void 0),B=q();let y;const F=()=>{if(y===void 0){const e=t.options?.pathToClaudeCodeExecutable;typeof e=="string"&&/\.(js|mjs|ts|tsx|jsx)$/.test(e)?(y=null,f.warn({pathToClaudeCodeExecutable:e},"agent.options.pathToClaudeCodeExecutable names a script rather than the native binary, so plugin marketplaces marked autoUpdate aren't refreshed")):(y=typeof e=="string"&&e||Z()||null,y||f.warn("couldn't find the Claude Code binary, so plugin marketplaces marked autoUpdate aren't refreshed"))}return y??void 0},S=t.keepAlive??ie,j=me(),E=re({start:t.start??(e=>L(e)),keepAlive:S,async*translate(e){for await(const c of e)yield*j(c)}}),K=async(e,c,l)=>je(c,_(d)?await Ce(e):[],l);return{name:"claude",describeStartupFailure(e,c){return`The Claude agent couldn't start in ${e}:
|
|
8
|
+
${c}
|
|
9
9
|
|
|
10
10
|
Bishop does not manage Anthropic credentials. The agent authenticates the
|
|
11
11
|
same way \`claude\` does in this directory, so make sure that works first:
|
|
12
12
|
ANTHROPIC_API_KEY in the environment or .env, or
|
|
13
|
-
an existing \`claude\` login on this machine.`},async check(
|
|
13
|
+
an existing \`claude\` login on this machine.`},async check(e,c){const l=new AbortController,p={text:""};try{const h=c?await K(e,c,p):void 0;await I(e,c);for await(const u of L({prompt:"ping",options:{...g({cwd:e,systemPrompt:void 0,abortController:l},void 0,h),maxTurns:1,persistSession:!1}})){if(u.type==="system"&&u.subtype==="init")return l.abort(),{ok:!0,credentialSource:ye(u.apiKeySource),...u.model?{model:u.model}:{}};if(u.type==="result")break}return{ok:!1,error:R("the harness exited without starting a session",p)}}catch(h){if(l.signal.aborted)return{ok:!0};const u=h instanceof Error?h.message:String(h);return{ok:!1,error:R(u,p)}}},async*runTurn(e){let c=!1;try{const l=await I(e.cwd,e.sandbox),p=m&&!e.sessionId,h=p?se({thread:e.threadKey}):void 0,u=!!S&&e.keepAlive===!0,x=_e(d,e.origin,e.worktree,e.cwd,u),w=r(e),G=E.run({threadId:e.threadId,threadKey:e.threadKey,text:le(e),fingerprint:{cwd:e.cwd,origin:{name:e.origin.name,self:e.origin.self},model:w.model,effort:w.effort,settings:l,sandbox:e.sandbox},...e.sessionId?{sessionId:e.sessionId}:{},keepAlive:u,...e.tools?{tools:e.tools}:{},server:ee,signal:e.signal,options:async()=>{const b={text:""},k=e.sandbox?await K(e.cwd,e.sandbox,b):void 0,T=g({cwd:e.cwd,systemPrompt:{type:"preset",preset:"claude_code",append:x},abortController:new AbortController,...e.sessionId?{resume:e.sessionId}:{}},e,k,l,p),D=p?F():void 0;return D&&await B({settings:T.settings,env:T.env??process.env,cwd:e.cwd,run:Ie(D,e.sandbox),context:{thread:e.threadKey},signal:e.signal}),{options:T,explain:Re(b)}}});for await(const b of G){h?.(b);for(const k of j(b))(k.type==="done"||k.type==="error")&&(c=!0),yield k}}catch(l){e.signal.aborted?f.debug({thread:e.threadKey},"claude turn aborted"):c?f.debug({err:l},"the agent failed after reporting a result"):(f.error({err:l},"harness turn failed"),yield{type:"error",kind:"harness_failure",message:l instanceof Error?l.message:String(l)})}},...S?{keepAlive:{attach:e=>E.attach(e),close:()=>E.close()}}:{}}}export{ve as BACKGROUND_REPORTS,Se as chosenGeneral,ze as claudeHarness,Te as claudeStateGrants,me as claudeTranslator,xe as editGuard,_e as systemPromptAppend,ge as toolDetail,ke as worktreeNote};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{spawn as B}from"node:child_process";import{randomBytes as
|
|
2
|
-
`);try{return await new Promise((p,w)=>{const u=setTimeout(()=>w(new Error(`codex app-server didn't answer within ${C}ms`)),C),
|
|
1
|
+
import{spawn as B}from"node:child_process";import{randomBytes as N}from"node:crypto";import{mkdir as P,realpath as M,rename as E,rm as H,stat as A}from"node:fs/promises";import{basename as R,dirname as v,isAbsolute as T,join as b,relative as W,resolve as G,sep as $}from"node:path";import{createInterface as U}from"node:readline";import{exec as X}from"../exec.js";import{log as O}from"../log.js";import{SERVER_NAME as L}from"../tools/server.js";import{isPlainObject as c,PLUGIN_INSTALL_TIMEOUT_MS as Y,unionLists as z,untilAborted as F}from"./layers.js";const C=1e4,_=".codex";function S(e){return typeof e=="string"?JSON.stringify(e):typeof e=="number"?Number.isNaN(e)?"nan":Number.isFinite(e)?String(e):e>0?"inf":"-inf":typeof e=="boolean"?String(e):Array.isArray(e)?`[${e.filter(t=>t!=null).map(S).join(",")}]`:c(e)?`{${Object.entries(e).filter(([,n])=>n!=null).map(([n,r])=>`${JSON.stringify(n)}=${S(r)}`).join(",")}}`:JSON.stringify(String(e))}function D(e,t){const n=c(e)?{...e}:{};for(const[r,s]of Object.entries(t)){const i=Object.hasOwn(n,r)?n[r]:void 0;n[r]=c(i)&&c(s)?{...i,...s}:s}return n}function pe(e,t){const n=Object.fromEntries(e.map(r=>[r,{trust_level:"trusted"}]));return`projects=${S(D(t,n))}`}function me(e,t){if(e.length===0)return;const n=Object.fromEntries(e.map(i=>[i.key,{trusted_hash:i.currentHash}])),r=c(t)?t:{},s={...r,state:D(r.state,n)};return`hooks=${S(s)}`}function K(e){const t=e?.plugins;return c(t)?Object.entries(t).filter(([,n])=>c(n)&&n.enabled===!0).map(([n])=>n):[]}function ge(e,t,n){const r=n.map(s=>b(s,_)+$);return e.filter(s=>s.source==="project"&&r.some(i=>s.sourcePath?.startsWith(i)??!1)||s.source==="plugin"&&s.pluginId!==null&&t.includes(s.pluginId))}function q(e,t){return Array.isArray(e)&&Array.isArray(t)?z(t,e):c(e)&&c(t)?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,q(r,Object.hasOwn(t,n)?t[n]:void 0)])):e}const he=["mcp_servers","notify","hooks","projects"];function j(e,t){let n=e;for(const r of t){if(!c(n)||!Object.hasOwn(n,r))return;n=n[r]}return n}const J=[{option:"sandboxMode",key:["sandbox_mode"]},{option:"networkAccessEnabled",key:["sandbox_workspace_write","network_access"]}];function we(e,t){const n=c(t?.config)?t.config:void 0,r={...e};for(const{option:s,key:i}of J)!(t!==void 0&&Object.hasOwn(t,s))&&j(n,i)!==void 0&&delete r[s];return r}function ye(e,t,n){const r=c(t?.config)?t.config:void 0,s={...e},i=[];for(const{option:f,key:g}of J)!(t!==void 0&&Object.hasOwn(t,f)||j(r,g)!==void 0)&&j(n,g)!==void 0&&Object.hasOwn(s,f)&&(delete s[f],i.push(f));return{options:s,yielded:i}}function ke(e){const t=e.developer_instructions;return typeof t=="string"&&t.trim()?t:void 0}async function be(e){return(await A(b(e,_)).catch(()=>{}))?.isDirectory()??!1}async function V(e){const t=await M(e).catch(()=>e);return[...new Set([e,t])]}async function Q(e,t,n,r){const s=B(e.command,[...t,"app-server"],{cwd:e.cwd,env:e.env,stdio:["pipe","pipe","pipe"],...r?{signal:r,killSignal:"SIGKILL"}:{}});let i="";s.stderr.setEncoding("utf8"),s.stderr.on("data",p=>{i=(i+p).slice(-2e3)}),s.stdin.on("error",()=>{});const f=U({input:s.stdout}),g=[];let d=0;const y=p=>s.stdin.write(`${JSON.stringify(p)}
|
|
2
|
+
`);try{return await new Promise((p,w)=>{const u=setTimeout(()=>w(new Error(`codex app-server didn't answer within ${C}ms`)),C),l=a=>{clearTimeout(u),a?w(a):p(g)},h=()=>{const a=n[d];if(!a)return l();d+=1,y({id:d,...a})};f.on("line",a=>{let m;try{m=JSON.parse(a)}catch{return}m.id===d&&(g.push(m),d===1&&y({method:"initialized"}),h())}),s.on("error",a=>l(a)),s.on("exit",a=>l(new Error(`codex app-server exited with code ${a}: ${i.trim()}`))),h()})}finally{f.close(),s.stdin.end(),s.kill()}}async function Oe(e,t,n){const r=e.cwd;let s;try{s=await Q(e,t.flatMap(o=>["-c",o]),[{method:"initialize",params:{clientInfo:{name:"bishop",version:"0"}}},{method:"config/read",params:{includeLayers:!0,cwd:r}},{method:"hooks/list",params:{cwds:[r]}}],n)}catch(o){return{ok:!1,reason:o instanceof Error?o.message:String(o)}}const[,i,f]=s;if(i?.error)return{ok:!1,reason:i.error.message??"config/read failed"};const g=i?.result?.layers,d=(await V(r)).map(o=>b(o,_)),p=(Array.isArray(g)?g:[]).find(o=>c(o)&&c(o.name)&&o.name.type==="project"&&d.includes(String(o.name.dotCodexFolder))&&!o.disabledReason&&c(o.config))?.config??{};if(c(p.mcp_servers)&&Object.hasOwn(p.mcp_servers,L))return{ok:!1,reason:`it declares an MCP server named "${L}", which is Bishop's`};f?.error&&O.warn({cwd:r,error:f.error.message},"codex couldn't list the agent's hooks, so none are approved this turn");const w=f?.result?.data?.[0],u=c(w)?w:{},l=[u.warnings,u.errors].flatMap(o=>Array.isArray(o)?o:[]).map(o=>c(o)?String(o.message):String(o));l.length>0&&O.warn({cwd:r,warnings:l},"codex reported problems with the agent's hooks; it skips those");const h=(Array.isArray(u.hooks)?u.hooks:[]).filter(o=>c(o)&&typeof o.key=="string"&&typeof o.currentHash=="string"),a=i?.result?.config,m=c(a)?a.plugins:void 0,k=c(m)?Object.entries(m).filter(([,o])=>c(o)&&o.enabled===!1).map(([o])=>o):[];return{ok:!0,project:{config:p,hooks:h,disabledPlugins:k}}}function Z(e,t){if(typeof e.source!="string"||!e.source)return;const n=e.source_type==="local"&&!T(e.source)?G(t,e.source):e.source,r=typeof e.ref=="string"&&e.ref?[`--ref=${e.ref}`]:[],s=Array.isArray(e.sparse_paths)?e.sparse_paths.filter(i=>typeof i=="string").map(i=>`--sparse=${i}`):[];return["plugin","marketplace","add",...r,...s,"--json","--",n]}function ee(e){const t=e.lastIndexOf("@");if(!(t<=0||t===e.length-1))return{plugin:e.slice(0,t),marketplace:e.slice(t+1)}}async function xe(e){const{launch:t,home:n,agent:r,operator:s,installed:i,context:f}=e,g=c(r.marketplaces)?r.marketplaces:{},d=new Map;for(const u of K(r)){if(j(s,["plugins",u,"enabled"])===!1||e.disabled?.includes(u))continue;const l=ee(u);if(l){if(!Object.hasOwn(g,l.marketplace)){await A(b(n,"plugins","cache",l.marketplace,l.plugin)).then(()=>!0).catch(()=>!1)||O.warn({...f,plugin:u},"the agent enables a plugin from a marketplace its config doesn't declare, so Bishop can't install it");continue}d.set(l.marketplace,[...d.get(l.marketplace)??[],u])}}const y=AbortSignal.timeout(e.timeoutMs??Y),p=[...d].flatMap(([u,l])=>{const h=g[u],a=c(h)?Z(h,t.cwd):void 0;if(!a)return O.warn({...f,marketplace:u},"the agent's marketplace declaration has no source, so its plugins aren't installed"),[];const m=JSON.stringify([n,a,l.sort()]),k=i.get(m);if(k?.done)return[];if(k)return[k.pending];const o={done:!1,pending:te({...e,name:u,addArgs:a,plugins:l,signal:y}).then(x=>(x.ok?o.done=!0:i.delete(m),x.added))};return i.set(m,o),[o.pending]});return p.length===0?!1:(await F(Promise.all(p),e.signal))?.some(Boolean)??!1}async function te(e){const{launch:t,home:n,name:r,addArgs:s,plugins:i,signal:f,context:g}=e,d={...g,marketplace:r};let y=!1;const p=b(n,".tmp",`bishop-plugins-${N(6).toString("hex")}`);try{await P(p,{recursive:!0});const w=await M(p),u=a=>X(t.command,a,{cwd:t.cwd,env:{...t.env,CODEX_HOME:w},signal:f}),l=await u(s);if(l.code!==0)return O.warn({...d,error:l.output.trim()||"timed out"},"plugins from a marketplace failed to install"),{ok:!1,added:y};let h=!0;for(const a of i){const m=await u(["plugin","add","--json","--",a]),k=ne(m.stdout);if(m.code!==0||!k){O.warn({...d,plugin:a,error:m.output.trim()||"timed out"},"a plugin failed to install"),h=!1;continue}const o=v(k),x=W(w,o);if(x.startsWith("..")||T(x)||!x.startsWith(b("plugins","cache")+$)){O.warn({...d,plugin:a,path:k},"codex installed a plugin somewhere Bishop did not expect"),h=!1;continue}const I=b(n,x);await A(b(I,R(k))).catch(()=>{})||(await re(o,I,w),y=!0)}return h&&O.info({...d,plugins:i},"installed plugins from a marketplace"),{ok:h,added:y}}catch(w){return O.warn({...d,err:w},"plugins from a marketplace failed to install"),{ok:!1,added:y}}finally{await H(p,{recursive:!0,force:!0}).catch(()=>{})}}function ne(e){try{const t=JSON.parse(e);return typeof t.installedPath=="string"?t.installedPath:void 0}catch{return}}async function re(e,t,n){await P(v(t),{recursive:!0});const r=b(n,`replaced-${N(4).toString("hex")}`),s=await E(t,r).then(()=>!0,i=>{if(i.code!=="ENOENT")throw i;return!1});try{await E(e,t)}catch(i){const f=i.code;if(f==="ENOTEMPTY"||f==="EEXIST")return;throw s&&await E(r,t).catch(()=>{}),i}}export{_ as CODEX_DIR,he as WHOLE_KEYS,ge as agentHooks,ke as agentInstructions,q as combineLists,K as enabledPlugins,be as hasProjectConfig,me as hookApprovals,Oe as inspectProject,xe as installPlugins,S as tomlInline,pe as trustOverride,V as trustedDirs,ye as yieldToAgent,we as yieldToOperatorConfig};
|
package/dist/harness/layers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(e){const t={...e.defaults,...e.configOptions};for(const[r,n]of Object.entries(e.general??{}))n!==void 0&&(t[r]=n);for(const r of e.controlledKeys)delete t[r];return t}function u(e,t){return!e||!t?[]:Object.entries(t).filter(([r,n])=>n!==void 0&&r in e).map(([r])=>r)}function s(e,t){return e?t.filter(r=>r in e):[]}function d(e,t){if(!(!e&&Object.keys(t).length===0))return{...process.env,...e,...t}}const c=6e4;function y(e,t){return t?t.aborted?Promise.resolve(void 0):new Promise((r,n)=>{const o=()=>r(void 0);t.addEventListener("abort",o,{once:!0}),e.then(i=>{t.removeEventListener("abort",o),r(i)},i=>{t.removeEventListener("abort",o),n(i)})}):e}function b(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function p(e,t){const r=new Set(e.map(n=>JSON.stringify(n)));return[...e,...t.filter(n=>!r.has(JSON.stringify(n)))]}export{c as PLUGIN_INSTALL_TIMEOUT_MS,s as ignoredKeys,b as isPlainObject,f as layerOptions,d as mergeEnv,u as shadowedKeys,p as unionLists,y as untilAborted};
|
package/dist/teams/create.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{randomUUID as
|
|
2
|
-
`)):c.length>0&&(g=c.map(l=>(f.set(l.ref,l),
|
|
1
|
+
import{randomUUID as x}from"node:crypto";import{readFile as I}from"node:fs/promises";import{App as M}from"@microsoft/teams.apps";import{BishopError as $}from"../errors.js";import{log as h}from"../log.js";import{retry as p}from"../retry.js";import{teamsRetryable as u}from"./api.js";import{teamsAllowList as S}from"./authorize.js";import{DOWNLOAD_TIMEOUT_MS as U,teamsFilesOf as v}from"./files.js";import{teamsGraph as C}from"./graph.js";import{createTeamsInterface as F}from"./interface.js";import{teamsLogger as k}from"./logger.js";import{createListener as P}from"./server.js";import{graphAddressOf as E}from"./thread.js";const D=3978,R="/healthz",_=500;async function B(e){const r=async(s,o)=>{try{return await I(s,"utf8")}catch(i){throw new $(`Couldn't read the TLS ${o} at ${s}: ${i.message}`,"ConfigError")}};return{cert:await r(e.cert,"certificate"),key:await r(e.key,"key")}}function w(e,r=[],s=[]){return{type:"message",text:e,...r.length>0?{attachments:r}:{},...s.length>0?{entities:s.map(o=>({type:"mention",mentioned:{id:o.id,name:o.name,role:"user"},text:o.text}))}:{}}}const q="application/vnd.microsoft.teams.card.file.consent",A="application/vnd.microsoft.teams.card.file.info";function L(e){if(!e||typeof e!="object")return;const r=e.ref;return typeof r=="string"?r:void 0}function j(e){const r={description:`Bishop wants to send ${e.name}.`,sizeInBytes:e.size,acceptContext:{ref:e.ref},declineContext:{ref:e.ref}};return{contentType:q,name:e.name,content:r}}function N(e){return{id:x(),contentType:A,contentUrl:e.webUrl,name:e.name,content:{uniqueId:e.uniqueId,fileType:e.fileType}}}async function z(e,r){const s=r.uploadInfo?.uploadUrl;if(!s)throw new Error("Teams returned no upload URL for the accepted file");const o=b(s),i=new Uint8Array(await I(e.path)),f=Math.max(0,i.byteLength-1),y=await fetch(o,{method:"PUT",headers:{"content-type":"application/octet-stream","content-length":String(i.byteLength),"content-range":`bytes 0-${f}/${i.byteLength}`},body:i});if(!y.ok)throw new Error(`Teams returned ${y.status} while receiving ${e.name}`)}async function de(e){const r=S(e.config?.allow),s=P({port:e.config?.port??D,healthPath:e.config?.healthPath??R,...e.config?.host?{host:e.config.host}:{},...e.config?.tls?{tls:await B(e.config.tls)}:{}}),o=new M({clientId:e.credentials.clientId,clientSecret:e.credentials.clientSecret,tenantId:e.credentials.tenantId,httpServerAdapter:s,logger:k()}),i=C(e.credentials),f=new Map,T=F({api:{async send(n,t,a){const c=a?.files??[];let d=t,g=[];a?.channel&&c.length>0?(g=(await Promise.all(c.map(m=>i.uploadChannelFile(a.channel,m)))).map(N),d=[t,...g.map(m=>`<attachment id="${m.id}"></attachment>`)].filter(Boolean).join(`
|
|
2
|
+
`)):c.length>0&&(g=c.map(l=>(f.set(l.ref,l),j(l))));try{const l=w(d,g,a?.mentions),m=await p(()=>o.send(n,l),{what:"teams send",retryable:u});return m?.id?{id:m.id}:void 0}catch(l){for(const m of c)f.delete(m.ref);throw l}},async update(n,t,a,c){await p(()=>o.api.conversations.updateActivity(n,t,w(a,[],c)),{what:"teams update",retryable:u})},async members(n){const t=await p(()=>o.api.conversations.getPagedMembers(n,_),{what:"teams roster page",retryable:u});return{members:t.members,complete:!t.continuationToken}},async channelInfo(n){return i.channel(n)},async channels(n){return i.channels(n)},async openChat(n){try{return(await p(()=>o.api.conversations.create({members:[{id:n,role:"user"}],tenantId:e.credentials.tenantId,channelData:{tenant:{id:e.credentials.tenantId}}}),{what:"teams open chat",retryable:u})).id}catch(t){if(t.response?.status===403)return;throw t}},async member(n,t){return await p(()=>o.api.conversations.getMemberById(n,t),{what:"teams roster",retryable:u})},async sharedFiles(n){const t=E(n);return t?i.files(t):[]},async history(n){const t=E(n);if(t)return i.conversation(t)},async fetchFile(n){const t=await fetch(b(n),{signal:AbortSignal.timeout(U)});if(!t.ok)throw new Error(`the download returned ${t.status}`);if(!t.body)throw new Error("the download sent no body");return t.body},async fetchAttachment(n){const t=b(n),a=new URL(o.api.serviceUrl);if(t.host!==a.host)throw h.warn({host:t.host,service:a.host},"refusing to send the app credential to a host that is not the Teams service"),new Error("the image is not hosted on the Teams service");const c=await o.api.http.get(t.toString(),{responseType:"arraybuffer",timeout:U});return G(c.data)},async fetchShared(n){return i.fetchShared(n)}},allow:r,...e.config?.verbosity?{verbosity:e.config.verbosity}:{},listener:s,meta:e.meta,model:e.model,...e.configuredModel?{configuredModel:e.configuredModel}:{},threads:e.threads,events:e.events,files:e.files,attachments:e.attachments,principals:e.principals,tenantId:e.credentials.tenantId,run:e.run,stop:e.stop});o.on("message",async({activity:n})=>{await T.handle(W(n))}),o.on("conversationUpdate",async({activity:n})=>{const t=n.channelData?.channel?.id,a=n.channelData?.team?.aadGroupId;T.changed({conversationId:n.conversation.id,...typeof t=="string"?{channelId:t}:{},...typeof a=="string"?{teamId:a}:{}})}),o.on("file.consent.accept",async({activity:n,send:t})=>(await O(n.value,t),{status:200})),o.on("file.consent.decline",async({activity:n,send:t})=>{const a=L(n.value.context),c=a?f.get(a):void 0;return a&&f.delete(a),c?(await t(w(`${c.name} was not sent because the file-consent request was declined.`)),{status:200}):(h.warn("received a Teams file-consent decline for an unknown file"),{status:200})});async function O(n,t){const a=L(n.context),c=a?f.get(a):void 0;if(a&&f.delete(a),!c){h.warn("received a Teams file-consent acceptance for an unknown file");return}try{await z(c,n);const d=n.uploadInfo;if(!d?.contentUrl||!d.uniqueId)throw new Error("Teams returned incomplete file information after the upload");await t(w(`${c.name} was sent.`,[{contentType:A,contentUrl:d.contentUrl,name:d.name??c.name,content:{uniqueId:d.uniqueId,fileType:d.fileType??c.mimeType}}]))}catch(d){h.warn({err:d,file:c.name},"could not finish a Teams file upload"),await t(w(`Could not send ${c.name}: ${d.message}`))}}return await o.initialize(),h.info({endpoint:o.server.messagingEndpoint},"the Teams app is mounted"),T}function b(e){const r=new URL(e);if(r.protocol!=="https:")throw new Error("the download URL is not HTTPS");return r}function G(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);throw new Error("the download came back as something other than bytes")}function H(e){const r=e.recipient?.id,s=r?e.stripMentionsText?.({accountId:r}):e;return(s?.stripMentionsText?.({tagOnly:!0})??s)?.text??e.text??""}function W(e){const r=K(e.channelData);return{id:e.id,conversationId:e.conversation.id,conversationType:typeof e.conversation.conversationType=="string"?e.conversation.conversationType:"channel",text:H(e),...J(e.attachments),mentioned:e.isRecipientMentioned?.()===!0,from:{id:e.from.id,...e.from.aadObjectId?{aadObjectId:e.from.aadObjectId}:{},...e.from.name?{name:e.from.name}:{}},...e.recipient?.id?{recipientId:e.recipient.id}:{},...e.recipient?.name?{recipientName:e.recipient.name}:{},files:v(e.attachments),...r?{channel:r}:{}}}function J(e){const r=e?.find(s=>s.contentType?.toLowerCase()==="text/html"&&typeof s.content=="string")?.content;return typeof r=="string"?{html:r}:{}}function K(e){const r=e?.team?.aadGroupId,s=e?.channel?.id;if(!(typeof r!="string"||typeof s!="string"))return{teamId:r,channelId:s}}export{de as createTeams,W as inboundOf};
|
package/dist/teams/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createServer as
|
|
1
|
+
import{createServer as T}from"node:http";import{createServer as p}from"node:https";import{BishopError as g}from"../errors.js";import{log as i}from"../log.js";const S=1024*1024,b=1e4,_=3e4;function B(r){try{return new URL(r??"/","http://localhost").pathname}catch{return}}async function O(r){let s=0;const c=[];for await(const d of r){if(s+=d.length,s>S)throw new Error(`body over ${S} bytes`);c.push(d)}return Buffer.concat(c).toString("utf8")}function h(r,s,c){if(c===void 0){r.writeHead(s),r.end();return}const d=JSON.stringify(c);r.writeHead(s,{"content-type":"application/json","content-length":Buffer.byteLength(d)}),r.end(d)}function k(r){const s=new Map,c=new Set;let d,m;const E=async(e,t)=>{const o=B(e.url);if(o!==void 0&&o===r.healthPath&&(e.method==="GET"||e.method==="HEAD")){h(t,200,{status:"ok"});return}const u=o!==void 0&&e.method==="POST"?s.get(o):void 0;if(!u){h(t,404);return}let l;try{const n=await O(e);l=n.length>0?JSON.parse(n):void 0}catch(n){i.debug({err:n,path:o},"rejected a malformed request body"),h(t,400);return}try{const n=await u({body:l,headers:e.headers});h(t,n.status,n.body)}catch(n){i.error({err:n,path:o},"the Teams endpoint failed to handle a request"),h(t,500)}},w=(e,t)=>{E(e,t).catch(o=>{i.error({err:o},"the Teams endpoint could not answer a request"),t.headersSent?t.destroy():h(t,500)})},a=r.tls?p({cert:r.tls.cert,key:r.tls.key},w):T(w);a.headersTimeout=b,a.requestTimeout=_,a.on("connection",e=>{c.add(e),e.on("close",()=>c.delete(e))});const y=r.host??"127.0.0.1";return{registerRoute(e,t,o){s.set(t,o),i.debug({method:e,path:t},"registered a route on the Teams endpoint")},start(e=r.port){const t=Number(e);return m=new Promise((o,u)=>{const l=n=>{const f=`${y}:${t}`;u(n.code==="EADDRINUSE"?new g(`Something is already listening on ${f}.`):n.code==="EACCES"?new g(`Not allowed to listen on ${f}.`):n)};a.once("error",l),a.listen(t,y,()=>{a.off("error",l),a.on("error",f=>{i.error({err:f},"the Teams endpoint failed")});const n=a.address();d=typeof n=="object"&&n?n.port:t,i.info({host:y,port:d,tls:!!r.tls,healthPath:r.healthPath},"the Teams endpoint is listening"),o()})}),m},async stop(){await m?.catch(()=>{}),await new Promise(e=>{if(!a.listening){e();return}a.close(()=>e());for(const t of c)t.destroy()})},get port(){return d??r.port}}}export{k as createListener};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentdeploymentco/bishop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "An agent gateway. Connects an agent to Slack, email, and Microsoft Teams.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"docs:preview": "npm --prefix docs run preview --"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
49
|
-
"@microsoft/teams.apps": "^2.0
|
|
48
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.318",
|
|
49
|
+
"@microsoft/teams.apps": "^2.2.0",
|
|
50
50
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
51
|
-
"@openai/codex-sdk": "0.
|
|
51
|
+
"@openai/codex-sdk": "0.166.0",
|
|
52
52
|
"@slack/bolt": "^5.1.0",
|
|
53
53
|
"@slack/types": "^3.2.0",
|
|
54
54
|
"@slack/web-api": "^8.2.0",
|